11 void InitEvtQueue(EvtQueue
*queue
)
19 void ResetEvtQueue(EvtQueue
*queue
)
28 ALenum
InsertEvtQueue(EvtQueue
*queue
, const MidiEvent
*evt
)
32 if(queue
->maxsize
== queue
->size
)
36 /* Queue has some stale entries, remove them to make space for more
38 memmove(&queue
->events
[0], &queue
->events
[queue
->pos
],
39 (queue
->size
-queue
->pos
)*sizeof(queue
->events
[0]));
40 queue
->size
-= queue
->pos
;
45 /* Queue is full, double the allocated space. */
49 newsize
= (queue
->maxsize
? (queue
->maxsize
<<1) : 16);
50 if(newsize
> queue
->maxsize
)
51 temp
= realloc(queue
->events
, newsize
* sizeof(queue
->events
[0]));
53 return AL_OUT_OF_MEMORY
;
56 queue
->maxsize
= newsize
;
63 ALsizei high
= queue
->size
- 1;
66 ALsizei mid
= pos
+ (high
-pos
)/2;
67 if(queue
->events
[mid
].time
< evt
->time
)
72 while(pos
< queue
->size
&& queue
->events
[pos
].time
<= evt
->time
)
76 memmove(&queue
->events
[pos
+1], &queue
->events
[pos
],
77 (queue
->size
-pos
)*sizeof(queue
->events
[0]));
80 queue
->events
[pos
] = *evt
;