quartz: Clear pending events when disabling notifications.

Based on a patch by Anton Baskanov.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-02-18 16:58:12 -06:00 committed by Alexandre Julliard
parent 99c0987289
commit aab10e6ca7
2 changed files with 23 additions and 11 deletions

View file

@ -319,6 +319,19 @@ static BOOL queue_media_event(struct filter_graph *graph, LONG code,
return TRUE;
}
static void flush_media_events(struct filter_graph *graph)
{
struct list *cursor;
while ((cursor = list_head(&graph->media_events)))
{
struct media_event *event = LIST_ENTRY(cursor, struct media_event, entry);
list_remove(&event->entry);
free(event);
}
}
static struct filter_graph *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, struct filter_graph, IUnknown_inner);
@ -443,14 +456,7 @@ static ULONG WINAPI FilterGraphInner_Release(IUnknown *iface)
if (This->pSite) IUnknown_Release(This->pSite);
while ((cursor = list_head(&This->media_events)))
{
struct media_event *event = LIST_ENTRY(cursor, struct media_event, entry);
list_remove(&event->entry);
free(event);
}
flush_media_events(This);
CloseHandle(This->media_event_handle);
This->cs.DebugInfo->Spare[0] = 0;
@ -4850,6 +4856,12 @@ static HRESULT WINAPI MediaEvent_SetNotifyFlags(IMediaEventEx *iface, LONG flags
graph->media_events_disabled = flags;
if (flags)
{
flush_media_events(graph);
ResetEvent(graph->media_event_handle);
}
return S_OK;
}

View file

@ -5215,10 +5215,10 @@ static void test_set_notify_flags(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(flags == AM_MEDIAEVENT_NONOTIFY, "Got flags %#x\n", flags);
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 = IMediaEventEx_GetEvent(media_event, &code, &param1, &param2, 50);
todo_wine ok(hr == E_ABORT, "Got hr %#x.\n", hr);
ok(hr == E_ABORT, "Got hr %#x.\n", hr);
hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status);
ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -5282,7 +5282,7 @@ static void test_set_notify_flags(void)
hr = IMediaEventEx_SetNotifyFlags(media_event, AM_MEDIAEVENT_NONOTIFY);
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 = IMediaControl_Stop(media_control);
ok(hr == S_OK, "Got hr %#x.\n", hr);