Make UEFI boot-platform build again
[haiku.git] / headers / os / media / TimedEventQueue.h
blob732fd1727beb7e8020847225cf64736fee496b8d
1 /*
2 * Copyright 2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _TIMED_EVENT_QUEUE_H
6 #define _TIMED_EVENT_QUEUE_H
8 #include <MediaDefs.h>
10 struct _event_queue_imp;
13 struct media_timed_event {
14 media_timed_event();
15 media_timed_event(bigtime_t inTime,
16 int32 inType);
17 media_timed_event(bigtime_t inTime,
18 int32 inType, void*inPointer,
19 uint32 inCleanup);
20 media_timed_event(
21 bigtime_t inTime, int32 inType,
22 void* inPointer, uint32 inCleanup,
23 int32 inData, int64 inBigdata,
24 char* inUserData, size_t dataSize = 0);
26 media_timed_event(
27 const media_timed_event& other);
29 ~media_timed_event();
31 // TODO: Should this not return "media_timed_event&" ?!
32 void operator=(const media_timed_event& other);
34 bigtime_t event_time;
35 int32 type;
36 void* pointer;
37 uint32 cleanup;
38 int32 data;
39 int64 bigdata;
40 char user_data[64];
42 uint32 _reserved_media_timed_event_[8];
46 bool operator==(const media_timed_event& a, const media_timed_event& b);
47 bool operator!=(const media_timed_event& a, const media_timed_event& b);
48 bool operator<(const media_timed_event& a, const media_timed_event& b);
49 bool operator>(const media_timed_event& a, const media_timed_event&b);
52 /*! A priority queue for holding media_timed_events. Sorts by increasing time,
53 so events near the front of the queue are to occur earlier.
55 class BTimedEventQueue {
56 public:
58 enum event_type {
59 B_NO_EVENT = -1, // Pushing this type will always fail.
60 B_ANY_EVENT = 0, // Pushing this type will always fail.
61 B_START,
62 B_STOP,
63 B_SEEK,
64 B_WARP,
65 B_TIMER,
66 B_HANDLE_BUFFER,
67 B_DATA_STATUS,
68 B_HARDWARE,
69 B_PARAMETER,
71 // User defined events are greater than this value.
72 B_USER_EVENT = 0x4000
75 enum cleanup_flag {
76 B_NO_CLEANUP = 0,
77 B_RECYCLE_BUFFER, // Specifies to recycle buffers handled by
78 // BTimedEventQueue.
79 B_EXPIRE_TIMER, // Specifies to call TimerExpired() on the
80 // event->data.
81 B_USER_CLEANUP = 0x4000
84 enum time_direction {
85 B_ALWAYS = -1,
86 B_BEFORE_TIME = 0,
87 B_AT_TIME,
88 B_AFTER_TIME
92 void* operator new(size_t size);
93 void operator delete(void* ptr, size_t size);
95 BTimedEventQueue();
96 virtual ~BTimedEventQueue();
98 status_t AddEvent(const media_timed_event& event);
99 status_t RemoveEvent(const media_timed_event* event);
100 status_t RemoveFirstEvent(
101 media_timed_event* _event = NULL);
103 bool HasEvents() const;
104 int32 EventCount() const;
107 const media_timed_event* FirstEvent() const;
108 bigtime_t FirstEventTime() const;
109 const media_timed_event* LastEvent() const;
110 bigtime_t LastEventTime() const;
112 const media_timed_event* FindFirstMatch(bigtime_t eventTime,
113 time_direction direction,
114 bool inclusive = true,
115 int32 eventType = B_ANY_EVENT);
118 // Queue manipulation
119 // Call DoForEach to perform a function on each event in the queue.
120 // Return an appropriate status defining an action to take for that event.
121 // DoForEach is an atomic operation ensuring the consistency of the queue
122 // during the call.
123 enum queue_action {
124 B_DONE = -1,
125 B_NO_ACTION = 0,
126 B_REMOVE_EVENT,
127 B_RESORT_QUEUE
129 typedef queue_action (*for_each_hook)(media_timed_event* event,
130 void* context);
132 status_t DoForEach(for_each_hook hook, void* context,
133 bigtime_t eventTime = 0,
134 time_direction direction = B_ALWAYS,
135 bool inclusive = true,
136 int32 eventType = B_ANY_EVENT);
139 // Flushing events
140 // The cleanup hook is called when events are flushed from the queue and
141 // the cleanup is not B_NO_CLEANUP or B_RECYCLE_BUFFER.
142 typedef void (*cleanup_hook)(const media_timed_event* event,
143 void* context);
144 void SetCleanupHook(cleanup_hook hook,
145 void* context);
146 status_t FlushEvents(bigtime_t eventTime,
147 time_direction direction,
148 bool inclusive = true,
149 int32 eventType = B_ANY_EVENT);
151 private:
152 // FBC padding and forbidden methods
153 BTimedEventQueue(
154 const BTimedEventQueue& other);
155 BTimedEventQueue& operator=(const BTimedEventQueue& other);
157 virtual status_t _Reserved_BTimedEventQueue_0(void*, ...);
158 virtual status_t _Reserved_BTimedEventQueue_1(void*, ...);
159 virtual status_t _Reserved_BTimedEventQueue_2(void*, ...);
160 virtual status_t _Reserved_BTimedEventQueue_3(void*, ...);
161 virtual status_t _Reserved_BTimedEventQueue_4(void*, ...);
162 virtual status_t _Reserved_BTimedEventQueue_5(void*, ...);
163 virtual status_t _Reserved_BTimedEventQueue_6(void*, ...);
164 virtual status_t _Reserved_BTimedEventQueue_7(void*, ...);
165 virtual status_t _Reserved_BTimedEventQueue_8(void*, ...);
166 virtual status_t _Reserved_BTimedEventQueue_9(void*, ...);
167 virtual status_t _Reserved_BTimedEventQueue_10(void*, ...);
168 virtual status_t _Reserved_BTimedEventQueue_11(void*, ...);
169 virtual status_t _Reserved_BTimedEventQueue_12(void*, ...);
170 virtual status_t _Reserved_BTimedEventQueue_13(void*, ...);
171 virtual status_t _Reserved_BTimedEventQueue_14(void*, ...);
172 virtual status_t _Reserved_BTimedEventQueue_15(void*, ...);
173 virtual status_t _Reserved_BTimedEventQueue_16(void*, ...);
174 virtual status_t _Reserved_BTimedEventQueue_17(void*, ...);
175 virtual status_t _Reserved_BTimedEventQueue_18(void*, ...);
176 virtual status_t _Reserved_BTimedEventQueue_19(void*, ...);
177 virtual status_t _Reserved_BTimedEventQueue_20(void*, ...);
178 virtual status_t _Reserved_BTimedEventQueue_21(void*, ...);
179 virtual status_t _Reserved_BTimedEventQueue_22(void*, ...);
180 virtual status_t _Reserved_BTimedEventQueue_23(void*, ...);
182 private:
183 _event_queue_imp* fImp;
185 uint32 _reserved_timed_event_queue_[6];
188 #endif