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