evr/presenter: Place early samples back to the front of the queue.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2022-04-06 17:41:58 +03:00 committed by Alexandre Julliard
parent 0957268103
commit 2bf3a58518
1 changed files with 10 additions and 5 deletions

View File

@ -429,15 +429,20 @@ static HRESULT video_presenter_sample_queue_init(struct video_presenter *present
return S_OK; return S_OK;
} }
static void video_presenter_sample_queue_push(struct video_presenter *presenter, IMFSample *sample) static void video_presenter_sample_queue_push(struct video_presenter *presenter, IMFSample *sample,
BOOL at_front)
{ {
struct sample_queue *queue = &presenter->thread.queue; struct sample_queue *queue = &presenter->thread.queue;
unsigned int idx;
EnterCriticalSection(&presenter->cs); EnterCriticalSection(&presenter->cs);
if (queue->used != queue->size) if (queue->used != queue->size)
{ {
queue->back = (queue->back + 1) % queue->size; if (at_front)
queue->samples[queue->back] = sample; idx = queue->front = (queue->size + queue->front - 1) % queue->size;
else
idx = queue->back = (queue->back + 1) % queue->size;
queue->samples[idx] = sample;
queue->used++; queue->used++;
IMFSample_AddRef(sample); IMFSample_AddRef(sample);
} }
@ -556,7 +561,7 @@ static void video_presenter_check_queue(struct video_presenter *presenter,
if (present) if (present)
video_presenter_sample_present(presenter, sample); video_presenter_sample_present(presenter, sample);
else else
video_presenter_sample_queue_push(presenter, sample); video_presenter_sample_queue_push(presenter, sample, TRUE);
IMFSample_Release(sample); IMFSample_Release(sample);
@ -580,7 +585,7 @@ static void video_presenter_schedule_sample(struct video_presenter *presenter, I
if (presenter->clock) if (presenter->clock)
{ {
video_presenter_sample_queue_push(presenter, sample); video_presenter_sample_queue_push(presenter, sample, FALSE);
PostThreadMessageW(presenter->thread.tid, EVRM_PRESENT, 0, 0); PostThreadMessageW(presenter->thread.tid, EVRM_PRESENT, 0, 0);
} }
else else