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
16media_timed_event::media_timed_event()
17{
18	CALLED();
19	memset(this, 0, sizeof(*this));
20}
21
22
23media_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
33media_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
47media_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
68media_timed_event::media_timed_event(const media_timed_event &clone)
69{
70	CALLED();
71	*this = clone;
72}
73
74
75void
76media_timed_event::operator=(const media_timed_event &clone)
77{
78	CALLED();
79	memcpy(this, &clone, sizeof(*this));
80}
81
82
83media_timed_event::~media_timed_event()
84{
85	CALLED();
86}
87
88/*************************************************************
89 * global operators
90 *************************************************************/
91
92bool 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
98bool 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
104bool operator<(const media_timed_event & a, const media_timed_event & b)
105{
106	CALLED();
107	return a.event_time < b.event_time;
108}
109
110bool 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
122void *
123BTimedEventQueue::operator new(size_t s)
124{
125	CALLED();
126	return ::operator new(s);
127}
128
129
130void
131BTimedEventQueue::operator delete(void *p, size_t s)
132{
133	CALLED();
134	return ::operator delete(p);
135}
136
137
138BTimedEventQueue::BTimedEventQueue() :
139	fImp(new _event_queue_imp)
140{
141	CALLED();
142}
143
144
145BTimedEventQueue::~BTimedEventQueue()
146{
147	CALLED();
148	delete fImp;
149}
150
151
152status_t
153BTimedEventQueue::AddEvent(const media_timed_event &event)
154{
155	CALLED();
156	return fImp->AddEvent(event);
157}
158
159
160status_t
161BTimedEventQueue::RemoveEvent(const media_timed_event *event)
162{
163	CALLED();
164	return fImp->RemoveEvent(event);
165}
166
167
168status_t
169BTimedEventQueue::RemoveFirstEvent(media_timed_event *outEvent)
170{
171	CALLED();
172	return fImp->RemoveFirstEvent(outEvent);
173}
174
175
176bool
177BTimedEventQueue::HasEvents() const
178{
179	CALLED();
180	return fImp->HasEvents();
181}
182
183
184int32
185BTimedEventQueue::EventCount() const
186{
187	CALLED();
188	return fImp->EventCount();
189}
190
191
192const media_timed_event *
193BTimedEventQueue::FirstEvent() const
194{
195	CALLED();
196	return fImp->FirstEvent();
197}
198
199
200bigtime_t
201BTimedEventQueue::FirstEventTime() const
202{
203	CALLED();
204	return fImp->FirstEventTime();
205}
206
207
208const media_timed_event *
209BTimedEventQueue::LastEvent() const
210{
211	CALLED();
212	return fImp->LastEvent();
213}
214
215
216bigtime_t
217BTimedEventQueue::LastEventTime() const
218{
219	CALLED();
220	return fImp->LastEventTime();
221}
222
223
224const media_timed_event *
225BTimedEventQueue::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
235status_t
236BTimedEventQueue::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
248void
249BTimedEventQueue::SetCleanupHook(cleanup_hook hook,
250								 void *context)
251{
252	CALLED();
253	fImp->SetCleanupHook(hook, context);
254}
255
256
257status_t
258BTimedEventQueue::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
273BTimedEventQueue::BTimedEventQueue(const BTimedEventQueue &other)
274BTimedEventQueue &BTimedEventQueue::operator=(const BTimedEventQueue &other)
275*/
276
277status_t BTimedEventQueue::_Reserved_BTimedEventQueue_0(void *, ...) { return B_ERROR; }
278status_t BTimedEventQueue::_Reserved_BTimedEventQueue_1(void *, ...) { return B_ERROR; }
279status_t BTimedEventQueue::_Reserved_BTimedEventQueue_2(void *, ...) { return B_ERROR; }
280status_t BTimedEventQueue::_Reserved_BTimedEventQueue_3(void *, ...) { return B_ERROR; }
281status_t BTimedEventQueue::_Reserved_BTimedEventQueue_4(void *, ...) { return B_ERROR; }
282status_t BTimedEventQueue::_Reserved_BTimedEventQueue_5(void *, ...) { return B_ERROR; }
283status_t BTimedEventQueue::_Reserved_BTimedEventQueue_6(void *, ...) { return B_ERROR; }
284status_t BTimedEventQueue::_Reserved_BTimedEventQueue_7(void *, ...) { return B_ERROR; }
285status_t BTimedEventQueue::_Reserved_BTimedEventQueue_8(void *, ...) { return B_ERROR; }
286status_t BTimedEventQueue::_Reserved_BTimedEventQueue_9(void *, ...) { return B_ERROR; }
287status_t BTimedEventQueue::_Reserved_BTimedEventQueue_10(void *, ...) { return B_ERROR; }
288status_t BTimedEventQueue::_Reserved_BTimedEventQueue_11(void *, ...) { return B_ERROR; }
289status_t BTimedEventQueue::_Reserved_BTimedEventQueue_12(void *, ...) { return B_ERROR; }
290status_t BTimedEventQueue::_Reserved_BTimedEventQueue_13(void *, ...) { return B_ERROR; }
291status_t BTimedEventQueue::_Reserved_BTimedEventQueue_14(void *, ...) { return B_ERROR; }
292status_t BTimedEventQueue::_Reserved_BTimedEventQueue_15(void *, ...) { return B_ERROR; }
293status_t BTimedEventQueue::_Reserved_BTimedEventQueue_16(void *, ...) { return B_ERROR; }
294status_t BTimedEventQueue::_Reserved_BTimedEventQueue_17(void *, ...) { return B_ERROR; }
295status_t BTimedEventQueue::_Reserved_BTimedEventQueue_18(void *, ...) { return B_ERROR; }
296status_t BTimedEventQueue::_Reserved_BTimedEventQueue_19(void *, ...) { return B_ERROR; }
297status_t BTimedEventQueue::_Reserved_BTimedEventQueue_20(void *, ...) { return B_ERROR; }
298status_t BTimedEventQueue::_Reserved_BTimedEventQueue_21(void *, ...) { return B_ERROR; }
299status_t BTimedEventQueue::_Reserved_BTimedEventQueue_22(void *, ...) { return B_ERROR; }
300status_t BTimedEventQueue::_Reserved_BTimedEventQueue_23(void *, ...) { return B_ERROR; }
301