Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/quartz/filtergraph.c | 28 ++++++++++++++++++++++++++++ dlls/quartz/tests/filtergraph.c | 14 +++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index d00d8898002..8705759c02d 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -154,6 +154,32 @@ static void EventsQueue_Clear(EventsQueue* omr) LeaveCriticalSection(&omr->msg_crst); }
+static void EventsQueue_RemoveEvent(EventsQueue* omr, LONG code) +{ + int write_pos; + int read_pos; + + EnterCriticalSection(&omr->msg_crst); + + write_pos = omr->msg_toget; + read_pos = omr->msg_toget; + while (read_pos != omr->msg_tosave) + { + if (omr->messages[read_pos].lEventCode != code) + { + omr->messages[write_pos] = omr->messages[read_pos]; + write_pos = (write_pos + 1 < omr->ring_buffer_size) ? write_pos + 1 : 0; + } + read_pos = (read_pos + 1 < omr->ring_buffer_size) ? read_pos + 1 : 0; + } + omr->msg_tosave = write_pos; + + if (omr->msg_toget == omr->msg_tosave) + ResetEvent(omr->msg_event); + + LeaveCriticalSection(&omr->msg_crst); +} + #define MAX_ITF_CACHE_ENTRIES 3 typedef struct _ITF_CACHE_ENTRY { const IID* riid; @@ -1760,6 +1786,8 @@ static HRESULT graph_start(struct filter_graph *graph, REFERENCE_TIME stream_sta graph->EcCompleteCount = 0; update_render_count(graph);
+ EventsQueue_RemoveEvent(&graph->evqueue, EC_COMPLETE); + if (graph->defaultclock && !graph->refClock) IFilterGraph2_SetDefaultSyncSource(&graph->IFilterGraph2_iface);
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index 2fa8675bae9..ae48d252851 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -5233,7 +5233,7 @@ static void test_set_notify_flags(void) hr = IMediaControl_Run(media_control); ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n"); + ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK, (LONG_PTR)&filter.IBaseFilter_iface); @@ -5277,9 +5277,9 @@ static void test_set_notify_flags(void) DestroyWindow(window); }
-#define check_events(a, b, c, d) check_events_(__LINE__, a, b, c, d) +#define check_events(a, b, c) check_events_(__LINE__, a, b, c) static void check_events_(unsigned int line, IMediaEventEx *media_event, - int expected_ec_complete_count, int expected_ec_status_count, BOOL todo) + int expected_ec_complete_count, int expected_ec_status_count) { int ec_complete_count = 0; int ec_status_count = 0; @@ -5297,7 +5297,7 @@ static void check_events_(unsigned int line, IMediaEventEx *media_event, ++ec_status_count; } ok(hr == E_ABORT, "Got hr %#x.\n", hr); - todo_wine_if(todo) ok_(__FILE__, line)(ec_complete_count == expected_ec_complete_count, + ok_(__FILE__, line)(ec_complete_count == expected_ec_complete_count, "Expected %d EC_COMPLETE events.\n", expected_ec_complete_count); ok_(__FILE__, line)(ec_status_count == expected_ec_status_count, "Expected %d EC_STATUS events.\n", expected_ec_status_count); @@ -5350,7 +5350,7 @@ static void test_events(void) hr = IMediaControl_Stop(media_control); ok(hr == S_OK, "Got hr %#x.\n", hr);
- check_events(media_event, 1, 2, FALSE); + check_events(media_event, 1, 2);
hr = IMediaControl_Run(media_control); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -5368,7 +5368,7 @@ static void test_events(void) hr = IMediaControl_Run(media_control); ok(hr == S_OK, "Got hr %#x.\n", hr);
- check_events(media_event, 0, 2, TRUE); + check_events(media_event, 0, 2);
hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -5383,7 +5383,7 @@ static void test_events(void) hr = IMediaControl_Pause(media_control); ok(hr == S_OK, "Got hr %#x.\n", hr);
- check_events(media_event, 1, 2, FALSE); + check_events(media_event, 1, 2);
SetEvent(event);