| Derived From: | – |
| Mix-in Classes: | – |
| Declared In: | be/media/TimedEventQueue.h |
| Library: | libmedia.so |
| Allocation: | Constructor only |
| Class Overview | |
status_t AddEvent(const media_timed_event& event);Adds the specified event to the queue.
RETURN CODES
B_OKThe event was added.
B_BAD_VALUE Unknown or invalid event type (you can't use
B_NO_EVENT
or B_ANY_EVENT).
B_NO_INITThe queue hasn't been initialized.
status_t DoForEach(for_each_hook hook,
void* context,
bigtime_t time,
time_direction direction,
bool inclusive = true,
int32 event = B_ANY_EVENT);For each event in the queue matching the specified parameters, the hook
function is called. The context pointer is passed through to the hook
function, and may point to anything your hook function requires.
Setting direction to
B_ALWAYS indicates that all events of the type
indicated by event should be processed. The
time and inclusive
arguments are ignored.
Setting direction to
B_BEFORE_TIME indicates that all matching events
occurring before the specified time should be
processed. If inclusive is
true, events occurring at
time are also processed.
Setting direction to
B_AT_TIME processes all matching events scheduled
at the specified time. The
inclusive argument is ignored.
If direction is
B_AFTER_TIME, all matching events scheduled to
occur after the specified time are processed. If
inclusive is true,
events scheduled to occur at time are also
processed.
This provides a means for you to scan through the queue and perform
a particular act on every node (or all nodes of a certain type, or that
occur at certain times). If you want to process all events, you can specify
a time of
B_INFINITE_TIMEOUT and a
direction of
B_BEFORE_TIME.
The hook function should return a queue_action value.
queue_actionMyHook(media_timed_event*event, void*context) { if (event->data== 0) { /* countdown finished, do something */ returnBTimedEventQueue::B_REMOVE_EVENT; }event->data--; returnBTimedEventQueue::B_NO_ACTION; }
In this example, the hook function processes the event (and indicates on
return that it should be removed from the queue) if the data field of the
event structure is zero; otherwise data is decremented and the event is
left alone.
RETURN CODES
B_OKThe events were processed.
B_ERRORAn undefined error occurred.
const media_timed_event* FindFirstMatch(bigtime_t eventTime,
time_direction direction,
bool inclusive = true,
int32 event = B_ANY_EVENT);Searches the event queue for the first event matching the given
specifications. The search begins at the time specified by
eventTime, and progresses in the specified
direction.
Setting direction to
B_ALWAYS indicates that all events of the type
indicated by event should be scanned. The
eventTime and
inclusive arguments are ignored.
Setting direction to
B_BEFORE_TIME indicates that all matching events
occurring before the specified eventTime should
be scanned. If inclusive is
true, events occurring at
eventTime are also scanned.
Setting direction to
B_AT_TIME scans all matching events scheduled at
the specified eventTime. The
inclusive argument is ignored.
If direction is
B_AFTER_TIME, all matching events scheduled to
occur after the specified eventTime are scanned.
If inclusive is true,
events scheduled to occur at eventTime are also
scanned.
If you want to scan all events, you can specify a time of
B_INFINITE_TIMEOUT and a direction of
B_BEFORE_TIME.
If no matching event is found, NULL is
returned.
const media_timed_event* FirstEvent() const;bigtime_t FirstEventTime() const;FirstEvent() returns the first event
in the queue, without removing it from the queue.
FirstEventTime() returns the first
event's time, in microseconds.
RETURN CODES
B_OKNo error occurred.
B_NO_INITThe queue hasn't been initialized.
B_INFINITE_TIMEOUTThe queue is empty (FirstEventTime() only).
status_t FlushEvents(bigtime_t time,
time_direction direction,
bool inclusive = true,
int32 event = B_ANY_EVENT) const;Flushes the specified events from the queue. You specify which events to
flush by indicating a time from which events should be flushed, a
direction in which to search for events to flush, and the type of events
to flush:
Setting direction to
B_ALWAYS indicates that all events of the type
indicated by event should be flushed. The
eventTime and
inclusive arguments are ignored.
Setting direction to
B_BEFORE_TIME indicates that all matching events
occurring before the specified eventTime should
be flushed. If inclusive is
true, events occurring at
eventTime are also flushed.
Setting direction to
B_AT_TIME flushes all matching events scheduled at
the specified eventTime. The
inclusive argument is ignored.
If direction is
B_AFTER_TIME, all matching events scheduled to
occur after the specified eventTime are flushed.
If inclusive is true,
events scheduled to occur at eventTime are also
flushed.
If you want to flush all events, you can specify a time of
B_INFINITE_TIMEOUT and a direction of
B_BEFORE_TIME.
RETURN CODES
B_OKThe events were flushed.
B_ERRORAn undefined error occurred.
const media_timed_event* LastEvent() const;bigtime_t LastEventTime() const;LastEvent() returns the last event
in the queue, without removing it from the queue.
LastEventTime() returns the last event's
time, in microseconds.
RETURN CODES
B_OKNo error occurred.
B_NO_INITThe queue hasn't been initialized.
B_INFINITE_TIMEOUTThe queue is empty (LastEventTime() only).
status_t RemoveEvent(const media_timed_event* event);status_t RemoveFirstEvent(const media_timed_event* event = NULL);RemoveEvent() removes the specified
event from the queue.
RemoveFirstEvent() removes the first
event from the queue. If outEvent
isn't NULL, the specified buffer is filled with a copy of the event
that's been removed.
RETURN CODES
B_OKThe event was removed.
B_NO_INITThe queue hasn't been initialized.
void SetCleanupHook(cleanup_hook hook,
void* context);Sets up the cleanup hook function specified by hook to be called for
events as they're removed from the queue. The hook will be called only
for events with
cleanup_flag
values of B_DELETE or B_USER_CLEANUP or
greater.
Declared in: be/media/TimedEventQueue.h
B_NO_CLEANUPDon't clean up when the event is removed from the queue.
B_RECYCLE_BUFFERBTimedEventQueue should recycle the buffer when the
buffer event is removed from the queue.
B_EXPIRE_TIMERCall
TimerExpired()
on the event's data field.
B_USER_CLEANUPBase value for user-defined cleanup types.
These values define how BTimedEventQueue
should handle removing events from the queue. If the flag is
B_USER_CLEANUP or greater, the cleanup hook
function is called when the event is removed.
Declared in: be/media/TimedEventQueue.h
B_NO_EVENTDon't push buffers of this type. It's a return value only.
B_ANY_EVENTDon't push buffers of this type; it's used in searches only.
B_STARTA start event.
B_STOPA stop event.
B_SEEKA seek event.
B_WARPA warp event.
B_TIMERA timer event.
B_HANDLE_BUFFERRepresents a buffer queued to be handled. The event's
pointer is a pointer to a
BBuffer
object.
B_DATA_STATUSRepresents a data status event.
B_HARDWAREA hardware event.
B_PARAMETERThe buffer contains changes to parameter values; pass it to
BControllable::ApplyParameterData().
B_USER_EVENTBase value for user-defined events.
These values describe type types of events that a
BTimedEventQueue can handle.
Declared in: be/media/TimedEventQueue.h
B_DONEEnd the
DoForEach()
pass.
B_NO_ACTIONDo nothing for this event.
B_REMOVE_EVENTRemove the event.
B_RESORT_QUEUESort the queue again to ensure that events are still in the right order.
These queue action values are returned by the hook function used by
DoForEach();
these values indicate what
DoForEach()
should do to the event after the hook has processed it.
Declared in: be/media/TimedEventQueue.h
B_ALWAYSMatches events occurring at any time.
B_BEFORE_TIMEMatches events occurring before a specified time.
B_AT_TIMEMatches events occurring at a specified time.
B_AFTER_TIMEMatches events occurring after a specified time.
These values are used to indicate a search direction through the time continuum.
Declared in: be/media/TimedEventQueue.h
typedef queue_action (*cleanup_hook)(media_timed_event*event, void*context);
The cleanup_hook type is used to define a hook
function called while removing an event from the queue; it's set by calling
SetCleanupHook().
Declared in: be/media/TimedEventQueue.h
typedef queue_action (*for_each_hook)(media_timed_event*event, void*context);
The for_each_hook type is used to define a hook function called by
DoForEach().
Declared in: be/media/TimedEventQueue.h
struct media_timed_event {media_timed_event();media_timed_event(bigtime_tinTime, int32inType);media_timed_event(bigtime_tinTime, int32inType, void*inPointer, uint32inCleanup);media_timed_event(bigtime_tinTime, int32inType, void*inPointer, uint32inCleanup, int32inData, int64inBigdata, char*inUserData, size_tdataSize= 0);media_timed_event(const media_timed_event&clone); voidoperator=(const media_timed_event&clone);~media_timed_event(); bigtime_tevent_time; int32type; void*pointer; uint32cleanup; int32data; int64bigdata; charuser_data[64]; uint32_reserved_media_timed_event_[8]; };
Describes a media event:
event_timeIndicates the time at which the event is scheduled to occur.
typeIndicates the type of event, as an event_type.
pointerIs a pointer to event-specific data owned by the event.
cleanupIs the cleanup_flag value for the event.
dataIs an event-specific 32-bit value.
bigdataIs an event-specific 64-bit value.
user_dataIs user-defined data.