Commit 7c0731e1 authored by Santino Mazza's avatar Santino Mazza Committed by Alexandre Julliard

evr: Create critical section for sample queue.

parent 072fe5d6
...@@ -66,6 +66,7 @@ struct sample_queue ...@@ -66,6 +66,7 @@ struct sample_queue
unsigned int front; unsigned int front;
unsigned int back; unsigned int back;
IMFSample *last_presented; IMFSample *last_presented;
CRITICAL_SECTION cs;
}; };
struct streaming_thread struct streaming_thread
...@@ -425,6 +426,7 @@ static HRESULT video_presenter_sample_queue_init(struct video_presenter *present ...@@ -425,6 +426,7 @@ static HRESULT video_presenter_sample_queue_init(struct video_presenter *present
queue->size = presenter->allocator_capacity; queue->size = presenter->allocator_capacity;
queue->back = queue->size - 1; queue->back = queue->size - 1;
InitializeCriticalSection(&queue->cs);
return S_OK; return S_OK;
} }
...@@ -435,7 +437,7 @@ static void video_presenter_sample_queue_push(struct video_presenter *presenter, ...@@ -435,7 +437,7 @@ static void video_presenter_sample_queue_push(struct video_presenter *presenter,
struct sample_queue *queue = &presenter->thread.queue; struct sample_queue *queue = &presenter->thread.queue;
unsigned int idx; unsigned int idx;
EnterCriticalSection(&presenter->cs); EnterCriticalSection(&queue->cs);
if (queue->used != queue->size) if (queue->used != queue->size)
{ {
if (at_front) if (at_front)
...@@ -446,14 +448,14 @@ static void video_presenter_sample_queue_push(struct video_presenter *presenter, ...@@ -446,14 +448,14 @@ static void video_presenter_sample_queue_push(struct video_presenter *presenter,
queue->used++; queue->used++;
IMFSample_AddRef(sample); IMFSample_AddRef(sample);
} }
LeaveCriticalSection(&presenter->cs); LeaveCriticalSection(&queue->cs);
} }
static BOOL video_presenter_sample_queue_pop(struct video_presenter *presenter, IMFSample **sample) static BOOL video_presenter_sample_queue_pop(struct video_presenter *presenter, IMFSample **sample)
{ {
struct sample_queue *queue = &presenter->thread.queue; struct sample_queue *queue = &presenter->thread.queue;
EnterCriticalSection(&presenter->cs); EnterCriticalSection(&queue->cs);
if (queue->used) if (queue->used)
{ {
*sample = queue->samples[queue->front]; *sample = queue->samples[queue->front];
...@@ -462,7 +464,7 @@ static BOOL video_presenter_sample_queue_pop(struct video_presenter *presenter, ...@@ -462,7 +464,7 @@ static BOOL video_presenter_sample_queue_pop(struct video_presenter *presenter,
} }
else else
*sample = NULL; *sample = NULL;
LeaveCriticalSection(&presenter->cs); LeaveCriticalSection(&queue->cs);
return *sample != NULL; return *sample != NULL;
} }
...@@ -477,6 +479,7 @@ static void video_presenter_sample_queue_free(struct video_presenter *presenter) ...@@ -477,6 +479,7 @@ static void video_presenter_sample_queue_free(struct video_presenter *presenter)
IMFSample_Release(sample); IMFSample_Release(sample);
free(queue->samples); free(queue->samples);
DeleteCriticalSection(&queue->cs);
} }
static HRESULT video_presenter_get_sample_surface(IMFSample *sample, IDirect3DSurface9 **surface) static HRESULT video_presenter_get_sample_surface(IMFSample *sample, IDirect3DSurface9 **surface)
...@@ -502,6 +505,7 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM ...@@ -502,6 +505,7 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM
{ {
IDirect3DSurface9 *surface, *backbuffer; IDirect3DSurface9 *surface, *backbuffer;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
struct sample_queue *queue = &presenter->thread.queue;
HRESULT hr; HRESULT hr;
if (FAILED(hr = video_presenter_get_sample_surface(sample, &surface))) if (FAILED(hr = video_presenter_get_sample_surface(sample, &surface)))
...@@ -527,12 +531,12 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM ...@@ -527,12 +531,12 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM
WARN("Failed to get a backbuffer, hr %#lx.\n", hr); WARN("Failed to get a backbuffer, hr %#lx.\n", hr);
} }
EnterCriticalSection(&presenter->cs); EnterCriticalSection(&queue->cs);
if (presenter->thread.queue.last_presented) if (queue->last_presented)
IMFSample_Release(presenter->thread.queue.last_presented); IMFSample_Release(queue->last_presented);
presenter->thread.queue.last_presented = sample; queue->last_presented = sample;
IMFSample_AddRef(presenter->thread.queue.last_presented); IMFSample_AddRef(queue->last_presented);
LeaveCriticalSection(&presenter->cs); LeaveCriticalSection(&queue->cs);
IDirect3DSurface9_Release(surface); IDirect3DSurface9_Release(surface);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment