Commit c76418fb authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Add a basic implementation of IWMSyncReader::OpenStream().

parent b51bfccd
......@@ -122,6 +122,9 @@ struct wm_reader
IWMReaderPlaylistBurn IWMReaderPlaylistBurn_iface;
IWMReaderTimecode IWMReaderTimecode_iface;
LONG refcount;
CRITICAL_SECTION cs;
IStream *source_stream;
const struct wm_reader_ops *ops;
};
......@@ -132,6 +135,9 @@ struct wm_reader_ops
void (*destroy)(struct wm_reader *reader);
};
void wm_reader_cleanup(struct wm_reader *reader);
HRESULT wm_reader_close(struct wm_reader *reader);
void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops);
HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream);
#endif /* __GST_PRIVATE_INCLUDED__ */
......@@ -1255,6 +1255,8 @@ static void async_reader_destroy(struct wm_reader *iface)
TRACE("reader %p.\n", reader);
wm_reader_close(&reader->reader);
wm_reader_cleanup(&reader->reader);
free(reader);
}
......
......@@ -759,6 +759,34 @@ static const IWMReaderTimecodeVtbl timecode_vtbl =
timecode_GetTimecodeRangeBounds,
};
HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream)
{
EnterCriticalSection(&reader->cs);
IStream_AddRef(reader->source_stream = stream);
LeaveCriticalSection(&reader->cs);
return S_OK;
}
HRESULT wm_reader_close(struct wm_reader *reader)
{
EnterCriticalSection(&reader->cs);
if (!reader->source_stream)
{
LeaveCriticalSection(&reader->cs);
return NS_E_INVALID_REQUEST;
}
IStream_Release(reader->source_stream);
reader->source_stream = NULL;
LeaveCriticalSection(&reader->cs);
return S_OK;
}
void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops)
{
reader->IWMHeaderInfo3_iface.lpVtbl = &header_info_vtbl;
......@@ -769,4 +797,13 @@ void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops)
reader->IWMReaderTimecode_iface.lpVtbl = &timecode_vtbl;
reader->refcount = 1;
reader->ops = ops;
InitializeCriticalSection(&reader->cs);
reader->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": wm_reader.cs");
}
void wm_reader_cleanup(struct wm_reader *reader)
{
reader->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&reader->cs);
}
......@@ -55,9 +55,11 @@ static ULONG WINAPI WMSyncReader_Release(IWMSyncReader2 *iface)
static HRESULT WINAPI WMSyncReader_Close(IWMSyncReader2 *iface)
{
struct sync_reader *This = impl_from_IWMSyncReader2(iface);
FIXME("(%p): stub!\n", This);
return E_NOTIMPL;
struct sync_reader *reader = impl_from_IWMSyncReader2(iface);
TRACE("reader %p.\n", reader);
return wm_reader_close(&reader->reader);
}
static HRESULT WINAPI WMSyncReader_GetMaxOutputSampleSize(IWMSyncReader2 *iface, DWORD output, DWORD *max)
......@@ -157,9 +159,11 @@ static HRESULT WINAPI WMSyncReader_Open(IWMSyncReader2 *iface, const WCHAR *file
static HRESULT WINAPI WMSyncReader_OpenStream(IWMSyncReader2 *iface, IStream *stream)
{
struct sync_reader *This = impl_from_IWMSyncReader2(iface);
FIXME("(%p)->(%p): stub!\n", This, stream);
return S_OK;
struct sync_reader *reader = impl_from_IWMSyncReader2(iface);
TRACE("reader %p, stream %p.\n", reader, stream);
return wm_reader_open_stream(&reader->reader, stream);
}
static HRESULT WINAPI WMSyncReader_SetOutputProps(IWMSyncReader2 *iface, DWORD output_num, IWMOutputMediaProps *output)
......@@ -309,6 +313,8 @@ static void sync_reader_destroy(struct wm_reader *iface)
TRACE("reader %p.\n", reader);
wm_reader_close(&reader->reader);
wm_reader_cleanup(&reader->reader);
free(reader);
}
......
......@@ -451,7 +451,7 @@ static void test_sync_reader_streaming(void)
hr = IWMSyncReader_OpenStream(reader, &stream.IStream_iface);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount);
ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount);
hr = IWMProfile_GetStreamCount(profile, NULL);
ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
......@@ -603,17 +603,17 @@ static void test_sync_reader_streaming(void)
todo_wine ok(hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr);
hr = IWMSyncReader_Close(reader);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IWMSyncReader_Close(reader);
todo_wine ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr);
ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr);
ok(stream.refcount == 1, "Got outstanding refcount %d.\n", stream.refcount);
SetFilePointer(stream.file, 0, NULL, FILE_BEGIN);
hr = IWMSyncReader_OpenStream(reader, &stream.IStream_iface);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount);
ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount);
IWMProfile_Release(profile);
ref = IWMSyncReader_Release(reader);
......@@ -692,7 +692,7 @@ static void test_sync_reader_types(void)
hr = IWMSyncReader_OpenStream(reader, &stream.IStream_iface);
ok(hr == S_OK, "Got hr %#x.\n", hr);
todo_wine ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount);
ok(stream.refcount > 1, "Got refcount %d.\n", stream.refcount);
for (i = 0; i < 2; ++i)
{
......
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