| Class Overview |
status_t AddEvent(const media_timed_event& event);
Adds the specified event to the queue.
Return Code | Description |
---|---|
| The event was added. |
| Unknown or invalid event type (you can't use
|
| The 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 Code | Description |
---|---|
| The events were processed. |
| An 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 Code | Description |
---|---|
| No error occurred. |
| The queue hasn't been initialized. |
| The queue is empty ( |
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 Code | Description |
---|---|
| The events were flushed. |
| An 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 Code | Description |
---|---|
| No error occurred. |
| The queue hasn't been initialized. |
| The queue is empty ( |
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 Code | Description |
---|---|
| The event was removed. |
| The 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: media/TimedEventQueue.h
Constant | Description |
---|---|
| Don't clean up when the event is removed from the queue. |
|
|
| Call
|
| Base 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: media/TimedEventQueue.h
Constant | Description |
---|---|
| Don't push buffers of this type. It's a return value only. |
| Don't push buffers of this type; it's used in searches only. |
| A start event. |
| A stop event. |
| A seek event. |
| A warp event. |
| A timer event. |
| Represents a buffer queued to be handled. The event's
pointer is a pointer to a
|
| Represents a data status event. |
| A hardware event. |
| The buffer contains changes to parameter values; pass it to
|
| Base value for user-defined events. |
These values describe type types of events that a
BTimedEventQueue
can handle.
Declared in: media/TimedEventQueue.h
Constant | Description |
---|---|
| End the
|
| Do nothing for this event. |
| Remove the event. |
| Sort 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: media/TimedEventQueue.h
Constant | Description |
---|---|
| Matches events occurring at any time. |
| Matches events occurring before a specified time. |
| Matches events occurring at a specified time. |
| Matches events occurring after a specified time. |
These values are used to indicate a search direction through the time continuum.
Declared in: 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: 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: 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:
Field | Description |
---|---|
| Indicates the time at which the event is scheduled to occur. |
| Indicates the type of event, as an event_type. |
| Is a pointer to event-specific data owned by the event. |
| Is the cleanup_flag value for the event. |
| Is an event-specific 32-bit value. |
| Is an event-specific 64-bit value. |
| Is user-defined data. |