From 4edad99303b807f03c001b11d03a8b251f1bd214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Fri, 10 Jun 2022 17:27:02 +0200 Subject: [PATCH] winegstreamer: Return E_UNEXPECTED from WMReaderAdvanced2_OpenStream when already opened. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon --- dlls/winegstreamer/wm_asyncreader.c | 7 +++++++ dlls/wmvcore/tests/wmvcore.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/dlls/winegstreamer/wm_asyncreader.c b/dlls/winegstreamer/wm_asyncreader.c index e70498b9858..97ee1fe60cd 100644 --- a/dlls/winegstreamer/wm_asyncreader.c +++ b/dlls/winegstreamer/wm_asyncreader.c @@ -725,6 +725,13 @@ static HRESULT WINAPI WMReaderAdvanced2_OpenStream(IWMReaderAdvanced6 *iface, EnterCriticalSection(&reader->reader.cs); + if (reader->reader.wg_parser) + { + LeaveCriticalSection(&reader->reader.cs); + WARN("Stream is already open; returning E_UNEXPECTED.\n"); + return E_UNEXPECTED; + } + if (SUCCEEDED(hr = wm_reader_open_stream(&reader->reader, stream))) open_stream(reader, callback, context); diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 59d1f5abcc6..f639184de90 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -2181,6 +2181,9 @@ static void test_async_reader_streaming(void) ret = WaitForSingleObject(callback.got_opened, 1000); ok(!ret, "Wait timed out.\n"); + hr = IWMReaderAdvanced2_OpenStream(advanced, &stream.IStream_iface, &callback.IWMReaderCallback_iface, (void **)0xdeadbee0); + ok(hr == E_UNEXPECTED, "Got hr %#lx.\n", hr); + count = 0xdeadbeef; hr = IWMReader_GetOutputCount(reader, &count); ok(hr == S_OK, "Got hr %#lx.\n", hr);