xref: /haiku/src/kits/media/TimedEventQueue.cpp (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
1 /***********************************************************************
2  * AUTHOR: Marcus Overhagen
3  *   FILE: TimedEventQueue.cpp
4  *  DESCR: used by BMediaEventLooper
5  ***********************************************************************/
6 
7 #define NDEBUG
8 #include <TimedEventQueue.h>
9 #include <string.h>
10 #include "TimedEventQueuePrivate.h"
11 #include "debug.h"
12 
13 /*************************************************************
14  * struct media_timed_event
15  *************************************************************/
16 
17 media_timed_event::media_timed_event()
18 {
19 	CALLED();
20 	memset(this, 0, sizeof(*this));
21 }
22 
23 
24 media_timed_event::media_timed_event(bigtime_t inTime,
25 									 int32 inType)
26 {
27 	CALLED();
28 	memset(this, 0, sizeof(*this));
29 	event_time = inTime;
30 	type = inType;
31 }
32 
33 
34 media_timed_event::media_timed_event(bigtime_t inTime,
35 									 int32 inType,
36 									 void *inPointer,
37 									 uint32 inCleanup)
38 {
39 	CALLED();
40 	memset(this, 0, sizeof(*this));
41 	event_time = inTime;
42 	type = inType;
43 	pointer = inPointer;
44 	cleanup = inCleanup;
45 }
46 
47 
48 media_timed_event::media_timed_event(bigtime_t inTime,
49 									 int32 inType,
50 									 void *inPointer,
51 									 uint32 inCleanup,
52 									 int32 inData,
53 									 int64 inBigdata,
54 									 char *inUserData,
55 									 size_t dataSize)
56 {
57 	CALLED();
58 	memset(this, 0, sizeof(*this));
59 	event_time = inTime;
60 	type = inType;
61 	pointer = inPointer;
62 	cleanup = inCleanup;
63 	data = inData;
64 	bigdata = inBigdata;
65 	memcpy(user_data,inUserData,min_c(sizeof(media_timed_event::user_data),dataSize));
66 }
67 
68 
69 media_timed_event::media_timed_event(const media_timed_event &clone)
70 {
71 	CALLED();
72 	*this = clone;
73 }
74 
75 
76 void
77 media_timed_event::operator=(const media_timed_event &clone)
78 {
79 	CALLED();
80 	memcpy(this, &clone, sizeof(*this));
81 }
82 
83 
84 media_timed_event::~media_timed_event()
85 {
86 	CALLED();
87 }
88 
89 /*************************************************************
90  * global operators
91  *************************************************************/
92 
93 bool operator==(const media_timed_event & a, const media_timed_event & b)
94 {
95 	CALLED();
96 	return (0 == memcmp(&a,&b,sizeof(media_timed_event)));
97 }
98 
99 bool operator!=(const media_timed_event & a, const media_timed_event & b)
100 {
101 	CALLED();
102 	return (0 != memcmp(&a,&b,sizeof(media_timed_event)));
103 }
104 
105 bool operator<(const media_timed_event & a, const media_timed_event & b)
106 {
107 	CALLED();
108 	return a.event_time < b.event_time;
109 }
110 
111 bool operator>(const media_timed_event & a, const media_timed_event &b)
112 {
113 	CALLED();
114 	return a.event_time > b.event_time;
115 }
116 
117 
118 /*************************************************************
119  * public BTimedEventQueue
120  *************************************************************/
121 
122 
123 void *
124 BTimedEventQueue::operator new(size_t s)
125 {
126 	CALLED();
127 	return ::operator new(s);
128 }
129 
130 
131 void
132 BTimedEventQueue::operator delete(void *p, size_t s)
133 {
134 	CALLED();
135 	return ::operator delete(p);
136 }
137 
138 
139 BTimedEventQueue::BTimedEventQueue() :
140 	fImp(new _event_queue_imp)
141 {
142 	CALLED();
143 }
144 
145 
146 BTimedEventQueue::~BTimedEventQueue()
147 {
148 	CALLED();
149 	delete fImp;
150 }
151 
152 
153 status_t
154 BTimedEventQueue::AddEvent(const media_timed_event &event)
155 {
156 	CALLED();
157 	return fImp->AddEvent(event);
158 }
159 
160 
161 status_t
162 BTimedEventQueue::RemoveEvent(const media_timed_event *event)
163 {
164 	CALLED();
165 	return fImp->RemoveEvent(event);
166 }
167 
168 
169 status_t
170 BTimedEventQueue::RemoveFirstEvent(media_timed_event *outEvent)
171 {
172 	CALLED();
173 	return fImp->RemoveFirstEvent(outEvent);
174 }
175 
176 
177 bool
178 BTimedEventQueue::HasEvents() const
179 {
180 	CALLED();
181 	return fImp->HasEvents();
182 }
183 
184 
185 int32
186 BTimedEventQueue::EventCount() const
187 {
188 	CALLED();
189 	return fImp->EventCount();
190 }
191 
192 
193 const media_timed_event *
194 BTimedEventQueue::FirstEvent() const
195 {
196 	CALLED();
197 	return fImp->FirstEvent();
198 }
199 
200 
201 bigtime_t
202 BTimedEventQueue::FirstEventTime() const
203 {
204 	CALLED();
205 	return fImp->FirstEventTime();
206 }
207 
208 
209 const media_timed_event *
210 BTimedEventQueue::LastEvent() const
211 {
212 	CALLED();
213 	return fImp->LastEvent();
214 }
215 
216 
217 bigtime_t
218 BTimedEventQueue::LastEventTime() const
219 {
220 	CALLED();
221 	return fImp->LastEventTime();
222 }
223 
224 
225 const media_timed_event *
226 BTimedEventQueue::FindFirstMatch(bigtime_t eventTime,
227 								 time_direction direction,
228 								 bool inclusive,
229 								 int32 eventType)
230 {
231 	CALLED();
232 	return fImp->FindFirstMatch(eventTime, direction, inclusive, eventType);
233 }
234 
235 
236 status_t
237 BTimedEventQueue::DoForEach(for_each_hook hook,
238 							void *context,
239 							bigtime_t eventTime,
240 							time_direction direction,
241 							bool inclusive,
242 							int32 eventType)
243 {
244 	CALLED();
245 	return fImp->DoForEach(hook, context, eventTime, direction, inclusive, eventType);
246 }
247 
248 
249 void
250 BTimedEventQueue::SetCleanupHook(cleanup_hook hook,
251 								 void *context)
252 {
253 	CALLED();
254 	fImp->SetCleanupHook(hook, context);
255 }
256 
257 
258 status_t
259 BTimedEventQueue::FlushEvents(bigtime_t eventTime,
260 							  time_direction direction,
261 							  bool inclusive,
262 							  int32 eventType)
263 {
264 	CALLED();
265 	return fImp->FlushEvents(eventTime, direction, inclusive, eventType);
266 }
267 
268 /*************************************************************
269  * private BTimedEventQueue
270  *************************************************************/
271 
272 /*
273 // unimplemented
274 BTimedEventQueue::BTimedEventQueue(const BTimedEventQueue &other)
275 BTimedEventQueue &BTimedEventQueue::operator=(const BTimedEventQueue &other)
276 */
277 
278 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_0(void *, ...) { return B_ERROR; }
279 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_1(void *, ...) { return B_ERROR; }
280 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_2(void *, ...) { return B_ERROR; }
281 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_3(void *, ...) { return B_ERROR; }
282 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_4(void *, ...) { return B_ERROR; }
283 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_5(void *, ...) { return B_ERROR; }
284 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_6(void *, ...) { return B_ERROR; }
285 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_7(void *, ...) { return B_ERROR; }
286 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_8(void *, ...) { return B_ERROR; }
287 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_9(void *, ...) { return B_ERROR; }
288 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_10(void *, ...) { return B_ERROR; }
289 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_11(void *, ...) { return B_ERROR; }
290 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_12(void *, ...) { return B_ERROR; }
291 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_13(void *, ...) { return B_ERROR; }
292 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_14(void *, ...) { return B_ERROR; }
293 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_15(void *, ...) { return B_ERROR; }
294 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_16(void *, ...) { return B_ERROR; }
295 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_17(void *, ...) { return B_ERROR; }
296 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_18(void *, ...) { return B_ERROR; }
297 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_19(void *, ...) { return B_ERROR; }
298 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_20(void *, ...) { return B_ERROR; }
299 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_21(void *, ...) { return B_ERROR; }
300 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_22(void *, ...) { return B_ERROR; }
301 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_23(void *, ...) { return B_ERROR; }
302