Commit 1fab216a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Use IWMSyncReader2_Close in the async reader.

parent 4a3f170c
......@@ -189,7 +189,6 @@ struct wm_reader
HRESULT WINAPI winegstreamer_create_wm_sync_reader(IUnknown *outer, void **out);
struct wm_reader *wm_reader_from_sync_reader_inner(IUnknown *inner);
HRESULT wm_reader_close(struct wm_reader *reader);
HRESULT wm_reader_get_max_stream_size(struct wm_reader *reader, WORD stream_number, DWORD *size);
HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output,
DWORD index, IWMOutputMediaProps **props);
......
......@@ -443,7 +443,7 @@ static ULONG WINAPI WMReader_Release(IWMReader *iface)
reader->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&reader->cs);
wm_reader_close(reader->wm_reader);
IWMSyncReader2_Close(reader->reader);
IUnknown_Release(reader->reader_inner);
free(reader);
......@@ -465,7 +465,7 @@ static HRESULT WINAPI WMReader_Open(IWMReader *iface, const WCHAR *url,
if (SUCCEEDED(hr = wm_reader_open_file(reader->wm_reader, url))
&& FAILED(hr = async_reader_open(reader, callback, context)))
wm_reader_close(reader->wm_reader);
IWMSyncReader2_Close(reader->reader);
LeaveCriticalSection(&reader->cs);
return hr;
......@@ -483,7 +483,7 @@ static HRESULT WINAPI WMReader_Close(IWMReader *iface)
if (SUCCEEDED(hr = async_reader_queue_op(reader, ASYNC_OP_CLOSE, NULL)))
{
async_reader_close(reader);
hr = wm_reader_close(reader->wm_reader);
hr = IWMSyncReader2_Close(reader->reader);
}
LeaveCriticalSection(&reader->cs);
......@@ -935,7 +935,7 @@ static HRESULT WINAPI WMReaderAdvanced2_OpenStream(IWMReaderAdvanced6 *iface,
if (SUCCEEDED(hr = wm_reader_open_stream(reader->wm_reader, stream))
&& FAILED(hr = async_reader_open(reader, callback, context)))
wm_reader_close(reader->wm_reader);
IWMSyncReader2_Close(reader->reader);
LeaveCriticalSection(&reader->cs);
return hr;
......
......@@ -1549,37 +1549,6 @@ HRESULT wm_reader_open_file(struct wm_reader *reader, const WCHAR *filename)
return hr;
}
HRESULT wm_reader_close(struct wm_reader *reader)
{
EnterCriticalSection(&reader->cs);
if (!reader->wg_parser)
{
LeaveCriticalSection(&reader->cs);
return NS_E_INVALID_REQUEST;
}
wg_parser_disconnect(reader->wg_parser);
reader->read_thread_shutdown = true;
WaitForSingleObject(reader->read_thread, INFINITE);
CloseHandle(reader->read_thread);
reader->read_thread = NULL;
wg_parser_destroy(reader->wg_parser);
reader->wg_parser = NULL;
if (reader->source_stream)
IStream_Release(reader->source_stream);
reader->source_stream = NULL;
if (reader->file)
CloseHandle(reader->file);
reader->file = NULL;
LeaveCriticalSection(&reader->cs);
return S_OK;
}
static struct wm_stream *wm_reader_get_stream_by_stream_number(struct wm_reader *reader, WORD stream_number)
{
if (stream_number && stream_number <= reader->stream_count)
......@@ -2180,7 +2149,7 @@ static ULONG WINAPI unknown_inner_Release(IUnknown *iface)
if (!refcount)
{
wm_reader_close(reader);
IWMSyncReader2_Close(&reader->IWMSyncReader2_iface);
reader->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&reader->cs);
......@@ -2227,7 +2196,33 @@ static HRESULT WINAPI reader_Close(IWMSyncReader2 *iface)
TRACE("reader %p.\n", reader);
return wm_reader_close(reader);
EnterCriticalSection(&reader->cs);
if (!reader->wg_parser)
{
LeaveCriticalSection(&reader->cs);
return NS_E_INVALID_REQUEST;
}
wg_parser_disconnect(reader->wg_parser);
reader->read_thread_shutdown = true;
WaitForSingleObject(reader->read_thread, INFINITE);
CloseHandle(reader->read_thread);
reader->read_thread = NULL;
wg_parser_destroy(reader->wg_parser);
reader->wg_parser = NULL;
if (reader->source_stream)
IStream_Release(reader->source_stream);
reader->source_stream = NULL;
if (reader->file)
CloseHandle(reader->file);
reader->file = NULL;
LeaveCriticalSection(&reader->cs);
return S_OK;
}
static HRESULT WINAPI reader_GetMaxOutputSampleSize(IWMSyncReader2 *iface, DWORD output, DWORD *max)
......
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