[PATCH v2 0/3] MR10458: quartz: Reset the completion event on paused -> running transition.
Otherwise, `WaitForCompletion` returns immediately because the completion event remains set. -- v2: quartz: Don't leak the completion event handle. quartz: Reset the completion event on paused -> running transition. quartz/tests: Add IMediaEvent(Ex)::WaitCompletion tests. https://gitlab.winehq.org/wine/wine/-/merge_requests/10458
From: Akihiro Sagawa <sagawa.aki@gmail.com> --- dlls/quartz/tests/filtergraph.c | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index a70601060c5..700bf36030f 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -5945,6 +5945,44 @@ static void test_events(void) hr = IMediaControl_Stop(media_control); ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IMediaEventEx_RestoreDefaultHandling(media_event, EC_COMPLETE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + /* Test WaitForCompletion(). */ + + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IMediaEventEx_WaitForCompletion(media_event, 0, &code); + ok(hr == E_ABORT, "Got hr %#lx.\n", hr); + + hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK, + (LONG_PTR)&filter.IBaseFilter_iface); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + code = 0xdeadbeef; + hr = IMediaEventEx_WaitForCompletion(media_event, 0, &code); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(code == EC_COMPLETE, "Got code %#lx.\n", code); + + hr = IMediaEventEx_WaitForCompletion(media_event, 0, &code); + todo_wine ok(hr == VFW_E_WRONG_STATE, "Got hr %#lx.\n", hr); + + hr = IMediaControl_Pause(media_control); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IMediaEventEx_WaitForCompletion(media_event, 0, &code); + ok(hr == VFW_E_WRONG_STATE, "Got hr %#lx.\n", hr); + + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IMediaEventEx_WaitForCompletion(media_event, 0, &code); + todo_wine ok(hr == E_ABORT, "Got hr %#lx.\n", hr); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + IMediaControl_Release(media_control); IMediaEventEx_Release(media_event); IMediaEventSink_Release(media_event_sink); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10458
From: Akihiro Sagawa <sagawa.aki@gmail.com> Otherwise, WaitForCompletion returns immediately because the completion event remains set. --- dlls/quartz/filtergraph.c | 1 + dlls/quartz/tests/filtergraph.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 17e5bb1c5b3..1fd82ca6be6 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -1791,6 +1791,7 @@ static HRESULT graph_start(struct filter_graph *graph, REFERENCE_TIME stream_sta } if (list_empty(&graph->media_events)) ResetEvent(graph->media_event_handle); + ResetEvent(graph->hEventCompletion); 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 700bf36030f..a3071c0db91 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -5978,7 +5978,7 @@ static void test_events(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IMediaEventEx_WaitForCompletion(media_event, 0, &code); - todo_wine ok(hr == E_ABORT, "Got hr %#lx.\n", hr); + ok(hr == E_ABORT, "Got hr %#lx.\n", hr); hr = IMediaControl_Stop(media_control); ok(hr == S_OK, "Got hr %#lx.\n", hr); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10458
From: Akihiro Sagawa <sagawa.aki@gmail.com> --- dlls/quartz/filtergraph.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 1fd82ca6be6..e4194f7d8eb 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -473,6 +473,7 @@ static ULONG WINAPI FilterGraphInner_Release(IUnknown *iface) flush_media_events(This); CloseHandle(This->media_event_handle); + CloseHandle(This->hEventCompletion); EnterCriticalSection(&message_cs); if (This->threaded && !--message_thread_refcount) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10458
v2, add the test in `test_events()` to avoid seeking. While creating the test, I found that the completion event handle `hEventCompletion` is not closed on destruction. In addition, `WaitForCompletion` does not behave correctly when `CancelDefaultHandling(EC_COMPLETE)` has been called beforehand. I've addressed the first issue in this MR, and I will submit a follow‑up MR for the second. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10458#note_135493
This merge request was approved by Elizabeth Figura. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10458
participants (3)
-
Akihiro Sagawa -
Akihiro Sagawa (@sgwaki) -
Elizabeth Figura (@zfigura)