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

winegstreamer: Use IWMSyncReader2_Open in the async reader.

parent 1fab216a
......@@ -199,7 +199,6 @@ HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackA
INSSBuffer **ret_sample, QWORD *pts, QWORD *duration, DWORD *flags, WORD *ret_stream_number);
HRESULT wm_reader_get_stream_selection(struct wm_reader *reader,
WORD stream_number, WMT_STREAM_SELECTION *selection);
HRESULT wm_reader_open_file(struct wm_reader *reader, const WCHAR *filename);
HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream);
void wm_reader_seek(struct wm_reader *reader, QWORD start, LONGLONG duration);
HRESULT wm_reader_set_allocate_for_output(struct wm_reader *reader, DWORD output, BOOL allocate);
......
......@@ -463,7 +463,7 @@ static HRESULT WINAPI WMReader_Open(IWMReader *iface, const WCHAR *url,
EnterCriticalSection(&reader->cs);
if (SUCCEEDED(hr = wm_reader_open_file(reader->wm_reader, url))
if (SUCCEEDED(hr = IWMSyncReader2_Open(reader->reader, url))
&& FAILED(hr = async_reader_open(reader, callback, context)))
IWMSyncReader2_Close(reader->reader);
......
......@@ -1510,45 +1510,6 @@ HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream)
return hr;
}
HRESULT wm_reader_open_file(struct wm_reader *reader, const WCHAR *filename)
{
LARGE_INTEGER size;
HANDLE file;
HRESULT hr;
if ((file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
{
ERR("Failed to open %s, error %lu.\n", debugstr_w(filename), GetLastError());
return HRESULT_FROM_WIN32(GetLastError());
}
if (!GetFileSizeEx(file, &size))
{
ERR("Failed to get the size of %s, error %lu.\n", debugstr_w(filename), GetLastError());
CloseHandle(file);
return HRESULT_FROM_WIN32(GetLastError());
}
EnterCriticalSection(&reader->cs);
if (reader->wg_parser)
{
LeaveCriticalSection(&reader->cs);
WARN("Stream is already open; returning E_UNEXPECTED.\n");
CloseHandle(file);
return E_UNEXPECTED;
}
reader->file = file;
if (FAILED(hr = init_stream(reader, size.QuadPart)))
reader->file = NULL;
LeaveCriticalSection(&reader->cs);
return hr;
}
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)
......@@ -2370,10 +2331,43 @@ static HRESULT WINAPI reader_GetStreamSelected(IWMSyncReader2 *iface,
static HRESULT WINAPI reader_Open(IWMSyncReader2 *iface, const WCHAR *filename)
{
struct wm_reader *reader = impl_from_IWMSyncReader2(iface);
LARGE_INTEGER size;
HANDLE file;
HRESULT hr;
TRACE("reader %p, filename %s.\n", reader, debugstr_w(filename));
return wm_reader_open_file(reader, filename);
if ((file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
{
ERR("Failed to open %s, error %lu.\n", debugstr_w(filename), GetLastError());
return HRESULT_FROM_WIN32(GetLastError());
}
if (!GetFileSizeEx(file, &size))
{
ERR("Failed to get the size of %s, error %lu.\n", debugstr_w(filename), GetLastError());
CloseHandle(file);
return HRESULT_FROM_WIN32(GetLastError());
}
EnterCriticalSection(&reader->cs);
if (reader->wg_parser)
{
LeaveCriticalSection(&reader->cs);
WARN("Stream is already open; returning E_UNEXPECTED.\n");
CloseHandle(file);
return E_UNEXPECTED;
}
reader->file = file;
if (FAILED(hr = init_stream(reader, size.QuadPart)))
reader->file = NULL;
LeaveCriticalSection(&reader->cs);
return hr;
}
static HRESULT WINAPI reader_OpenStream(IWMSyncReader2 *iface, IStream *stream)
......
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