Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_reader.c | 8 ++++++-- dlls/wmvcore/tests/wmvcore.c | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 12d1f04c270..2de0610165d 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -243,8 +243,12 @@ static HRESULT WINAPI buffer_GetMaxLength(INSSBuffer *iface, DWORD *size)
static HRESULT WINAPI buffer_GetBuffer(INSSBuffer *iface, BYTE **data) { - FIXME("iface %p, data %p, stub!\n", iface, data); - return E_NOTIMPL; + struct buffer *buffer = impl_from_INSSBuffer(iface); + + TRACE("buffer %p, data %p.\n", buffer, data); + + *data = buffer->data; + return S_OK; }
static HRESULT WINAPI buffer_GetBufferAndLength(INSSBuffer *iface, BYTE **data, DWORD *size) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 0e7c6380c92..685dd92e27e 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -602,9 +602,9 @@ static void test_sync_reader_streaming(void) IWMProfile *profile; QWORD pts, duration; INSSBuffer *sample; + BYTE *data, *data2; HANDLE file; HRESULT hr; - BYTE *data; BOOL ret;
file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0); @@ -677,6 +677,11 @@ static void test_sync_reader_streaming(void) { hr = INSSBuffer_GetBufferAndLength(sample, &data, &size); ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = INSSBuffer_GetBuffer(sample, &data2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(data2 == data, "Data pointers didn't match.\n"); + ref = INSSBuffer_Release(sample); ok(!ref, "Got outstanding refcount %d.\n", ref);
@@ -737,6 +742,11 @@ static void test_sync_reader_streaming(void) { hr = INSSBuffer_GetBufferAndLength(sample, &data, &size); ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = INSSBuffer_GetBuffer(sample, &data2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(data2 == data, "Data pointers didn't match.\n"); + ref = INSSBuffer_Release(sample); ok(!ref, "Got outstanding refcount %d.\n", ref); } @@ -1183,9 +1193,9 @@ static HRESULT WINAPI callback_OnSample(IWMReaderCallback *iface, DWORD output, QWORD time, QWORD duration, DWORD flags, INSSBuffer *sample, void *context) { struct callback *callback = impl_from_IWMReaderCallback(iface); + BYTE *data, *data2; HRESULT hr; DWORD size; - BYTE *data;
if (winetest_debug > 1) trace("%u: %04x: IWMReaderCallback::OnSample(output %u, time %I64u, duration %I64u, flags %#x)\n", @@ -1196,6 +1206,10 @@ static HRESULT WINAPI callback_OnSample(IWMReaderCallback *iface, DWORD output, hr = INSSBuffer_GetBufferAndLength(sample, &data, &size); ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = INSSBuffer_GetBuffer(sample, &data2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(data2 == data, "Data pointers didn't match.\n"); + ok(callback->got_started > 0, "Got %u WMT_STARTED callbacks.\n", callback->got_started); ok(!callback->got_eof, "Got %u WMT_EOF callbacks.\n", callback->got_eof); ++callback->got_sample;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_reader.c | 8 ++++++-- dlls/wmvcore/tests/wmvcore.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 2de0610165d..2c0f89e29a9 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -237,8 +237,12 @@ static HRESULT WINAPI buffer_SetLength(INSSBuffer *iface, DWORD size)
static HRESULT WINAPI buffer_GetMaxLength(INSSBuffer *iface, DWORD *size) { - FIXME("iface %p, size %p, stub!\n", iface, size); - return E_NOTIMPL; + struct buffer *buffer = impl_from_INSSBuffer(iface); + + TRACE("buffer %p, size %p.\n", buffer, size); + + *size = buffer->size; + return S_OK; }
static HRESULT WINAPI buffer_GetBuffer(INSSBuffer *iface, BYTE **data) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 685dd92e27e..0347195ba10 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -591,7 +591,7 @@ static void test_reader_attributes(IWMProfile *profile)
static void test_sync_reader_streaming(void) { - DWORD size, flags, output_number, expect_output_number; + DWORD size, capacity, flags, output_number, expect_output_number; const WCHAR *filename = load_resource(L"test.wmv"); WORD stream_numbers[2], stream_number; IWMStreamConfig *config, *config2; @@ -682,6 +682,10 @@ static void test_sync_reader_streaming(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(data2 == data, "Data pointers didn't match.\n");
+ hr = INSSBuffer_GetMaxLength(sample, &capacity); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(size <= capacity, "Size %u exceeds capacity %u.\n", size, capacity); + ref = INSSBuffer_Release(sample); ok(!ref, "Got outstanding refcount %d.\n", ref);
@@ -747,6 +751,10 @@ static void test_sync_reader_streaming(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(data2 == data, "Data pointers didn't match.\n");
+ hr = INSSBuffer_GetMaxLength(sample, &capacity); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(size <= capacity, "Size %u exceeds capacity %u.\n", size, capacity); + ref = INSSBuffer_Release(sample); ok(!ref, "Got outstanding refcount %d.\n", ref); } @@ -1193,9 +1201,9 @@ static HRESULT WINAPI callback_OnSample(IWMReaderCallback *iface, DWORD output, QWORD time, QWORD duration, DWORD flags, INSSBuffer *sample, void *context) { struct callback *callback = impl_from_IWMReaderCallback(iface); + DWORD size, capacity; BYTE *data, *data2; HRESULT hr; - DWORD size;
if (winetest_debug > 1) trace("%u: %04x: IWMReaderCallback::OnSample(output %u, time %I64u, duration %I64u, flags %#x)\n", @@ -1210,6 +1218,10 @@ static HRESULT WINAPI callback_OnSample(IWMReaderCallback *iface, DWORD output, ok(hr == S_OK, "Got hr %#x.\n", hr); ok(data2 == data, "Data pointers didn't match.\n");
+ hr = INSSBuffer_GetMaxLength(sample, &capacity); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(size <= capacity, "Size %u exceeds capacity %u.\n", size, capacity); + ok(callback->got_started > 0, "Got %u WMT_STARTED callbacks.\n", callback->got_started); ok(!callback->got_eof, "Got %u WMT_EOF callbacks.\n", callback->got_eof); ++callback->got_sample;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_reader.c | 17 ++++++++++++----- dlls/wmvcore/tests/wmvcore.c | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 2c0f89e29a9..b9e1a1b3d03 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -172,7 +172,7 @@ struct buffer INSSBuffer INSSBuffer_iface; LONG refcount;
- DWORD size; + DWORD size, capacity; BYTE data[1]; };
@@ -231,8 +231,15 @@ static HRESULT WINAPI buffer_GetLength(INSSBuffer *iface, DWORD *size)
static HRESULT WINAPI buffer_SetLength(INSSBuffer *iface, DWORD size) { - FIXME("iface %p, size %u, stub!\n", iface, size); - return E_NOTIMPL; + struct buffer *buffer = impl_from_INSSBuffer(iface); + + TRACE("iface %p, size %u.\n", buffer, size); + + if (size > buffer->capacity) + return E_INVALIDARG; + + buffer->size = size; + return S_OK; }
static HRESULT WINAPI buffer_GetMaxLength(INSSBuffer *iface, DWORD *size) @@ -241,7 +248,7 @@ static HRESULT WINAPI buffer_GetMaxLength(INSSBuffer *iface, DWORD *size)
TRACE("buffer %p, size %p.\n", buffer, size);
- *size = buffer->size; + *size = buffer->capacity; return S_OK; }
@@ -1754,7 +1761,7 @@ HRESULT wm_reader_get_stream_sample(struct wm_stream *stream,
object->INSSBuffer_iface.lpVtbl = &buffer_vtbl; object->refcount = 1; - object->size = event.u.buffer.size; + object->capacity = object->size = event.u.buffer.size;
if (!wg_parser_stream_copy_buffer(wg_stream, object->data, 0, object->size)) { diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 0347195ba10..f8962b784ac 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -686,6 +686,17 @@ static void test_sync_reader_streaming(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(size <= capacity, "Size %u exceeds capacity %u.\n", size, capacity);
+ hr = INSSBuffer_SetLength(sample, capacity + 1); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = INSSBuffer_SetLength(sample, capacity - 1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = INSSBuffer_GetBufferAndLength(sample, &data2, &size); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(data2 == data, "Data pointers didn't match.\n"); + ok(size == capacity - 1, "Expected size %u, got %u.\n", capacity - 1, size); + ref = INSSBuffer_Release(sample); ok(!ref, "Got outstanding refcount %d.\n", ref);
@@ -1222,6 +1233,17 @@ static HRESULT WINAPI callback_OnSample(IWMReaderCallback *iface, DWORD output, ok(hr == S_OK, "Got hr %#x.\n", hr); ok(size <= capacity, "Size %u exceeds capacity %u.\n", size, capacity);
+ hr = INSSBuffer_SetLength(sample, capacity + 1); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = INSSBuffer_SetLength(sample, capacity - 1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = INSSBuffer_GetBufferAndLength(sample, &data2, &size); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(data2 == data, "Data pointers didn't match.\n"); + ok(size == capacity - 1, "Expected size %u, got %u.\n", capacity - 1, size); + ok(callback->got_started > 0, "Got %u WMT_STARTED callbacks.\n", callback->got_started); ok(!callback->got_eof, "Got %u WMT_EOF callbacks.\n", callback->got_eof); ++callback->got_sample;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_asyncreader.c | 19 ++++++++--- dlls/wmvcore/tests/wmvcore.c | 49 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/dlls/winegstreamer/wm_asyncreader.c b/dlls/winegstreamer/wm_asyncreader.c index 4193d7d75de..b7b96c8b884 100644 --- a/dlls/winegstreamer/wm_asyncreader.c +++ b/dlls/winegstreamer/wm_asyncreader.c @@ -188,11 +188,22 @@ static ULONG WINAPI WMReader_Release(IWMReader *iface) return IWMProfile3_Release(&reader->reader.IWMProfile3_iface); }
-static HRESULT WINAPI WMReader_Open(IWMReader *iface, const WCHAR *url, IWMReaderCallback *callback, void *context) +static HRESULT WINAPI WMReader_Open(IWMReader *iface, const WCHAR *url, + IWMReaderCallback *callback, void *context) { - struct async_reader *This = impl_from_IWMReader(iface); - FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(url), callback, context); - return E_NOTIMPL; + struct async_reader *reader = impl_from_IWMReader(iface); + HRESULT hr; + + TRACE("reader %p, url %s, callback %p, context %p.\n", + reader, debugstr_w(url), callback, context); + + EnterCriticalSection(&reader->reader.cs); + + if (SUCCEEDED(hr = wm_reader_open_file(&reader->reader, url))) + open_stream(reader, callback, context); + + LeaveCriticalSection(&reader->reader.cs); + return hr; }
static HRESULT WINAPI WMReader_Close(IWMReader *iface) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index f8962b784ac..591ecf209eb 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -1613,6 +1613,54 @@ static void test_async_reader_types(void) ok(ret, "Failed to delete %s, error %u.\n", debugstr_w(filename), GetLastError()); }
+static void test_async_reader_file(void) +{ + const WCHAR *filename = load_resource(L"test.wmv"); + struct callback callback; + IWMReader *reader; + DWORD count; + HRESULT hr; + ULONG ref; + BOOL ret; + + callback_init(&callback); + + hr = WMCreateReader(NULL, 0, &reader); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IWMReader_Open(reader, filename, &callback.IWMReaderCallback_iface, (void **)0xdeadbeef); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(callback.refcount > 1, "Got refcount %d.\n", callback.refcount); + ret = WaitForSingleObject(callback.got_opened, 1000); + ok(!ret, "Wait timed out.\n"); + + count = 0xdeadbeef; + hr = IWMReader_GetOutputCount(reader, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 2, "Got count %u.\n", count); + + hr = IWMReader_Start(reader, 0, 0, 1.0f, (void *)0xfacade); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IWMReader_Close(reader); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(callback.got_closed == 1, "Got %u WMT_CLOSED callbacks.\n", callback.got_closed); + ok(callback.refcount == 1, "Got outstanding refcount %d.\n", callback.refcount); + callback_cleanup(&callback); + + hr = IWMReader_Close(reader); + ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr); + + ref = IWMReader_Release(reader); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ok(callback.got_closed == 1, "Got %u WMT_CLOSED callbacks.\n", callback.got_closed); + ok(callback.refcount == 1, "Got outstanding refcount %d.\n", callback.refcount); + callback_cleanup(&callback); + + ret = DeleteFileW(filename); + ok(ret, "Failed to delete %s, error %u.\n", debugstr_w(filename), GetLastError()); +} + START_TEST(wmvcore) { HRESULT hr; @@ -1634,6 +1682,7 @@ START_TEST(wmvcore) test_sync_reader_file(); test_async_reader_streaming(); test_async_reader_types(); + test_async_reader_file();
CoUninitialize(); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_reader.c | 8 ++++++-- dlls/wmvcore/tests/wmvcore.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index b9e1a1b3d03..bcae50e5d1e 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -85,8 +85,12 @@ static ULONG WINAPI output_props_Release(IWMOutputMediaProps *iface)
static HRESULT WINAPI output_props_GetType(IWMOutputMediaProps *iface, GUID *major_type) { - FIXME("iface %p, major_type %p, stub!\n", iface, major_type); - return E_NOTIMPL; + const struct output_props *props = impl_from_IWMOutputMediaProps(iface); + + TRACE("iface %p, major_type %p.\n", iface, major_type); + + *major_type = props->mt.majortype; + return S_OK; }
static HRESULT WINAPI output_props_GetMediaType(IWMOutputMediaProps *iface, WM_MEDIA_TYPE *mt, DWORD *size) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 591ecf209eb..ec66fb1bb74 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -861,12 +861,12 @@ static void test_sync_reader_types(void) bool got_video = false, got_audio = false; DWORD size, ret_size, output_number; WORD stream_number, stream_number2; + GUID majortype, majortype2; struct teststream stream; IWMStreamConfig *config; ULONG count, ref, i, j; IWMSyncReader *reader; IWMProfile *profile; - GUID majortype; HANDLE file; HRESULT hr; BOOL ret; @@ -923,6 +923,12 @@ static void test_sync_reader_types(void) hr = IWMOutputMediaProps_GetMediaType(output_props, mt, &ret_size); ok(hr == S_OK, "Got hr %#x.\n", hr);
+ memset(&majortype2, 0xcc, sizeof(majortype2)); + hr = IWMOutputMediaProps_GetType(output_props, &majortype2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&majortype2, &majortype), "Expected major type %s, got %s.\n", + debugstr_guid(&majortype), debugstr_guid(&majortype2)); + ref = IWMOutputMediaProps_Release(output_props); ok(!ref, "Got outstanding refcount %d.\n", ref);
@@ -981,6 +987,12 @@ static void test_sync_reader_types(void) else check_video_type(mt);
+ memset(&majortype2, 0xcc, sizeof(majortype2)); + hr = IWMOutputMediaProps_GetType(output_props, &majortype2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&majortype2, &majortype), "Expected major type %s, got %s.\n", + debugstr_guid(&majortype), debugstr_guid(&majortype2)); + hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IWMSyncReader_SetOutputProps(reader, 1 - output_number, output_props); @@ -1398,13 +1410,13 @@ static void test_async_reader_types(void) bool got_video = false, got_audio = false; DWORD size, ret_size, output_number; IWMReaderAdvanced2 *advanced; + GUID majortype, majortype2; struct teststream stream; struct callback callback; IWMStreamConfig *config; ULONG count, ref, i, j; IWMProfile *profile; IWMReader *reader; - GUID majortype; HANDLE file; HRESULT hr; BOOL ret; @@ -1458,11 +1470,17 @@ static void test_async_reader_types(void) ret_size = sizeof(mt_buffer); hr = IWMOutputMediaProps_GetMediaType(output_props, mt, &ret_size); ok(hr == S_OK, "Got hr %#x.\n", hr); + majortype = mt->majortype; + + memset(&majortype2, 0xcc, sizeof(majortype2)); + hr = IWMOutputMediaProps_GetType(output_props, &majortype2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&majortype2, &majortype), "Expected major type %s, got %s.\n", + debugstr_guid(&majortype), debugstr_guid(&majortype2));
ref = IWMOutputMediaProps_Release(output_props); ok(!ref, "Got outstanding refcount %d.\n", ref);
- majortype = mt->majortype; if (IsEqualGUID(&majortype, &MEDIATYPE_Audio)) { got_audio = true; @@ -1538,6 +1556,12 @@ static void test_async_reader_types(void) else check_video_type(mt);
+ memset(&majortype2, 0xcc, sizeof(majortype2)); + hr = IWMOutputMediaProps_GetType(output_props, &majortype2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&majortype2, &majortype), "Expected major type %s, got %s.\n", + debugstr_guid(&majortype), debugstr_guid(&majortype2)); + hr = IWMReader_SetOutputProps(reader, output_number, output_props); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IWMReader_SetOutputProps(reader, 1 - output_number, output_props);