dmsynth: Use time instead of position to order events.

Different time values can map to the same position.
This commit is contained in:
Anton Baskanov 2023-11-11 12:39:50 +07:00 committed by Alexandre Julliard
parent 2c08013b8c
commit 88c7e93575

View file

@ -322,6 +322,7 @@ struct preset
struct event
{
struct list entry;
REFERENCE_TIME time;
LONGLONG position;
BYTE midi[3];
};
@ -973,11 +974,12 @@ static HRESULT WINAPI synth_PlayBuffer(IDirectMusicSynth8 *iface,
{
if (!(event = calloc(1, sizeof(*event)))) return E_OUTOFMEMORY;
memcpy(event->midi, data, head->cbEvent);
event->time = time + head->rtDelta;
event->position = position;
EnterCriticalSection(&This->cs);
LIST_FOR_EACH_ENTRY(next_event, &This->events, struct event, entry)
if (next_event->position > event->position) break;
if (next_event->time > event->time) break;
list_add_before(&next_event->entry, &event->entry);
LeaveCriticalSection(&This->cs);
}