Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/sar.c | 145 ++++++++++++++++++++++++++++++++++++++++++++- dlls/mf/tests/mf.c | 19 +++--- 2 files changed, 152 insertions(+), 12 deletions(-)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index 4f20472748..eda3957ac2 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -26,13 +26,154 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
-static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, IUnknown **obj) +struct audio_renderer +{ + IMFMediaSink IMFMediaSink_iface; + LONG refcount; +}; + +static struct audio_renderer *impl_from_IMFMediaSink(IMFMediaSink *iface) +{ + return CONTAINING_RECORD(iface, struct audio_renderer, IMFMediaSink_iface); +} + +static HRESULT audio_renderer_sink_QueryInterface(IMFMediaSink *iface, REFIID riid, void **obj) +{ + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj); + + if (IsEqualIID(riid, &IID_IMFMediaSink) || + IsEqualIID(riid, &IID_IUnknown)) + { + *obj = iface; + IMFMediaSink_AddRef(iface); + return S_OK; + } + + WARN("Unsupported %s.\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI audio_renderer_sink_AddRef(IMFMediaSink *iface) +{ + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface); + ULONG refcount = InterlockedIncrement(&renderer->refcount); + TRACE("%p, refcount %u.\n", iface, refcount); + return refcount; +} + +static ULONG WINAPI audio_renderer_sink_Release(IMFMediaSink *iface) +{ + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface); + ULONG refcount = InterlockedDecrement(&renderer->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + if (!refcount) + heap_free(renderer); + + return refcount; +} + +static HRESULT WINAPI audio_renderer_sink_GetCharacteristics(IMFMediaSink *iface, DWORD *flags) +{ + FIXME("%p, %p.\n", iface, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_AddStreamSink(IMFMediaSink *iface, DWORD stream_sink_id, + IMFMediaType *media_type, IMFStreamSink **stream_sink) +{ + FIXME("%p, %#x, %p, %p.\n", iface, stream_sink_id, media_type, stream_sink); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_RemoveStreamSink(IMFMediaSink *iface, DWORD stream_sink_id) +{ + FIXME("%p, %#x.\n", iface, stream_sink_id); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_GetStreamSinkCount(IMFMediaSink *iface, DWORD *count) { - FIXME("%p, %p, %p.\n", attributes, user_context, obj); + FIXME("%p, %p.\n", iface, count);
return E_NOTIMPL; }
+static HRESULT WINAPI audio_renderer_sink_GetStreamSinkByIndex(IMFMediaSink *iface, DWORD index, + IMFStreamSink **stream) +{ + FIXME("%p, %u, %p.\n", iface, index, stream); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_GetStreamSinkById(IMFMediaSink *iface, DWORD stream_sink_id, + IMFStreamSink **stream) +{ + FIXME("%p, %#x, %p.\n", iface, stream_sink_id, stream); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock) +{ + FIXME("%p, %p.\n", iface, clock); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_GetPresentationClock(IMFMediaSink *iface, IMFPresentationClock **clock) +{ + FIXME("%p, %p.\n", iface, clock); + + return E_NOTIMPL; +} + +static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface) +{ + FIXME("%p.\n", iface); + + return E_NOTIMPL; +} + +static const IMFMediaSinkVtbl audio_renderer_sink_vtbl = +{ + audio_renderer_sink_QueryInterface, + audio_renderer_sink_AddRef, + audio_renderer_sink_Release, + audio_renderer_sink_GetCharacteristics, + audio_renderer_sink_AddStreamSink, + audio_renderer_sink_RemoveStreamSink, + audio_renderer_sink_GetStreamSinkCount, + audio_renderer_sink_GetStreamSinkByIndex, + audio_renderer_sink_GetStreamSinkById, + audio_renderer_sink_SetPresentationClock, + audio_renderer_sink_GetPresentationClock, + audio_renderer_sink_Shutdown, +}; + +static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, IUnknown **obj) +{ + struct audio_renderer *renderer; + + TRACE("%p, %p, %p.\n", attributes, user_context, obj); + + if (!(renderer = heap_alloc_zero(sizeof(*renderer)))) + return E_OUTOFMEMORY; + + renderer->IMFMediaSink_iface.lpVtbl = &audio_renderer_sink_vtbl; + renderer->refcount = 1; + + *obj = (IUnknown *)&renderer->IMFMediaSink_iface; + + return S_OK; +} + static void sar_shutdown_object(void *user_context, IUnknown *obj) { /* FIXME: shut down sink */ diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index dfbd928f60..46024d3fba 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2650,15 +2650,14 @@ static void test_sar(void) CoUninitialize(); return; } - -todo_wine ok(hr == S_OK, "Failed to create renderer, hr %#x.\n", hr);
-if (SUCCEEDED(hr)) -{ hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&time_source); +todo_wine ok(hr == S_OK, "Failed to get time source interface, hr %#x.\n", hr);
+if (SUCCEEDED(hr)) +{ hr = IMFPresentationTimeSource_GetUnderlyingClock(time_source, &clock); ok(hr == MF_E_NO_CLOCK, "Unexpected hr %#x.\n", hr);
@@ -2679,31 +2678,30 @@ if (SUCCEEDED(hr)) IMFClockStateSink_Release(state_sink);
IMFPresentationTimeSource_Release(time_source); - - IMFMediaSink_Release(sink); } + IMFMediaSink_Release(sink); + /* Activation */ hr = MFCreateAudioRendererActivate(&activate); ok(hr == S_OK, "Failed to create activation object, hr %#x.\n", hr);
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink); -todo_wine ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
-if (hr == S_OK) -{ hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink2); ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr); ok(sink == sink2, "Unexpected instance.\n"); IMFMediaSink_Release(sink2);
hr = IMFMediaSink_GetCharacteristics(sink, &flags); +todo_wine ok(hr == S_OK, "Failed to get sink flags, hr %#x.\n", hr);
hr = IMFActivate_ShutdownObject(activate); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags); +todo_wine ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
IMFMediaSink_Release(sink); @@ -2712,13 +2710,14 @@ if (hr == S_OK) ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags); +todo_wine ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
IMFMediaSink_Release(sink);
hr = IMFActivate_DetachObject(activate); ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); -} + IMFActivate_Release(activate);
CoUninitialize();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/sar.c | 46 ++++++++++++++++++++++++++++++++++++++-------- dlls/mf/tests/mf.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 9 deletions(-)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index eda3957ac2..a23807df64 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -19,6 +19,7 @@ #define COBJMACROS
#include "mfidl.h" +#include "mferror.h" #include "mf_private.h"
#include "wine/debug.h" @@ -30,6 +31,8 @@ struct audio_renderer { IMFMediaSink IMFMediaSink_iface; LONG refcount; + BOOL is_shut_down; + CRITICAL_SECTION cs; };
static struct audio_renderer *impl_from_IMFMediaSink(IMFMediaSink *iface) @@ -70,7 +73,10 @@ static ULONG WINAPI audio_renderer_sink_Release(IMFMediaSink *iface) TRACE("%p, refcount %u.\n", iface, refcount);
if (!refcount) + { + DeleteCriticalSection(&renderer->cs); heap_free(renderer); + }
return refcount; } @@ -85,23 +91,37 @@ static HRESULT WINAPI audio_renderer_sink_GetCharacteristics(IMFMediaSink *iface static HRESULT WINAPI audio_renderer_sink_AddStreamSink(IMFMediaSink *iface, DWORD stream_sink_id, IMFMediaType *media_type, IMFStreamSink **stream_sink) { - FIXME("%p, %#x, %p, %p.\n", iface, stream_sink_id, media_type, stream_sink); + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
- return E_NOTIMPL; + TRACE("%p, %#x, %p, %p.\n", iface, stream_sink_id, media_type, stream_sink); + + return renderer->is_shut_down ? MF_E_SHUTDOWN : MF_E_STREAMSINKS_FIXED; }
static HRESULT WINAPI audio_renderer_sink_RemoveStreamSink(IMFMediaSink *iface, DWORD stream_sink_id) { - FIXME("%p, %#x.\n", iface, stream_sink_id); + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
- return E_NOTIMPL; + TRACE("%p, %#x.\n", iface, stream_sink_id); + + return renderer->is_shut_down ? MF_E_SHUTDOWN : MF_E_STREAMSINKS_FIXED; }
static HRESULT WINAPI audio_renderer_sink_GetStreamSinkCount(IMFMediaSink *iface, DWORD *count) { - FIXME("%p, %p.\n", iface, count); + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, count); + + if (!count) + return E_POINTER; + + if (renderer->is_shut_down) + return MF_E_SHUTDOWN; + + *count = 1; + + return S_OK; }
static HRESULT WINAPI audio_renderer_sink_GetStreamSinkByIndex(IMFMediaSink *iface, DWORD index, @@ -136,9 +156,18 @@ static HRESULT WINAPI audio_renderer_sink_GetPresentationClock(IMFMediaSink *ifa
static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface) { - FIXME("%p.\n", iface); + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
- return E_NOTIMPL; + TRACE("%p.\n", iface); + + if (renderer->is_shut_down) + return MF_E_SHUTDOWN; + + EnterCriticalSection(&renderer->cs); + renderer->is_shut_down = TRUE; + LeaveCriticalSection(&renderer->cs); + + return S_OK; }
static const IMFMediaSinkVtbl audio_renderer_sink_vtbl = @@ -168,6 +197,7 @@ static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context,
renderer->IMFMediaSink_iface.lpVtbl = &audio_renderer_sink_vtbl; renderer->refcount = 1; + InitializeCriticalSection(&renderer->cs);
*obj = (IUnknown *)&renderer->IMFMediaSink_iface;
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 46024d3fba..578c5bcaf7 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2634,10 +2634,11 @@ static void test_sar(void) IMFPresentationTimeSource *time_source; IMFClockStateSink *state_sink; IMFMediaSink *sink, *sink2; + IMFStreamSink *stream_sink; IMFActivate *activate; MFCLOCK_STATE state; + DWORD flags, count; IMFClock *clock; - DWORD flags; HRESULT hr;
hr = CoInitialize(NULL); @@ -2679,6 +2680,38 @@ if (SUCCEEDED(hr))
IMFPresentationTimeSource_Release(time_source); } + hr = IMFMediaSink_AddStreamSink(sink, 123, NULL, &stream_sink); + ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_RemoveStreamSink(sink, 0); + ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_GetStreamSinkCount(sink, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_GetStreamSinkCount(sink, &count); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(count == 1, "Unexpected count %u.\n", count); + + /* Shutdown */ + hr = IMFMediaSink_Shutdown(sink); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); + + hr = IMFMediaSink_Shutdown(sink); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_AddStreamSink(sink, 123, NULL, &stream_sink); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_RemoveStreamSink(sink, 0); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_GetStreamSinkCount(sink, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + + hr = IMFMediaSink_GetStreamSinkCount(sink, &count); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + IMFMediaSink_Release(sink);
/* Activation */
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69070
Your paranoid android.
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:175:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The win32 Wine build failed
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:175:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The wow32 Wine build failed
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/sar.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 5 deletions(-)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index a23807df64..1a00ac4198 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -30,6 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mfplat); struct audio_renderer { IMFMediaSink IMFMediaSink_iface; + IMFMediaSinkPreroll IMFMediaSinkPreroll_iface; LONG refcount; BOOL is_shut_down; CRITICAL_SECTION cs; @@ -40,21 +41,36 @@ static struct audio_renderer *impl_from_IMFMediaSink(IMFMediaSink *iface) return CONTAINING_RECORD(iface, struct audio_renderer, IMFMediaSink_iface); }
+static struct audio_renderer *impl_from_IMFMediaSinkPreroll(IMFMediaSinkPreroll *iface) +{ + return CONTAINING_RECORD(iface, struct audio_renderer, IMFMediaSinkPreroll_iface); +} + static HRESULT audio_renderer_sink_QueryInterface(IMFMediaSink *iface, REFIID riid, void **obj) { + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IMFMediaSink) || IsEqualIID(riid, &IID_IUnknown)) { *obj = iface; - IMFMediaSink_AddRef(iface); - return S_OK; + } + else if (IsEqualIID(riid, &IID_IMFMediaSinkPreroll)) + { + *obj = &renderer->IMFMediaSinkPreroll_iface; + } + else + { + WARN("Unsupported %s.\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; }
- WARN("Unsupported %s.\n", debugstr_guid(riid)); - *obj = NULL; - return E_NOINTERFACE; + IUnknown_AddRef((IUnknown *)*obj); + + return S_OK; }
static ULONG WINAPI audio_renderer_sink_AddRef(IMFMediaSink *iface) @@ -186,6 +202,39 @@ static const IMFMediaSinkVtbl audio_renderer_sink_vtbl = audio_renderer_sink_Shutdown, };
+static HRESULT WINAPI audio_renderer_preroll_QueryInterface(IMFMediaSinkPreroll *iface, REFIID riid, void **obj) +{ + struct audio_renderer *renderer = impl_from_IMFMediaSinkPreroll(iface); + return IMFMediaSink_QueryInterface(&renderer->IMFMediaSink_iface, riid, obj); +} + +static ULONG WINAPI audio_renderer_preroll_AddRef(IMFMediaSinkPreroll *iface) +{ + struct audio_renderer *renderer = impl_from_IMFMediaSinkPreroll(iface); + return IMFMediaSink_AddRef(&renderer->IMFMediaSink_iface); +} + +static ULONG WINAPI audio_renderer_preroll_Release(IMFMediaSinkPreroll *iface) +{ + struct audio_renderer *renderer = impl_from_IMFMediaSinkPreroll(iface); + return IMFMediaSink_Release(&renderer->IMFMediaSink_iface); +} + +static HRESULT WINAPI audio_renderer_preroll_NotifyPreroll(IMFMediaSinkPreroll *iface, MFTIME start_time) +{ + FIXME("%p, %s.\n", iface, debugstr_time(start_time)); + + return E_NOTIMPL; +} + +static const IMFMediaSinkPrerollVtbl audio_renderer_preroll_vtbl = +{ + audio_renderer_preroll_QueryInterface, + audio_renderer_preroll_AddRef, + audio_renderer_preroll_Release, + audio_renderer_preroll_NotifyPreroll, +}; + static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, IUnknown **obj) { struct audio_renderer *renderer; @@ -196,6 +245,7 @@ static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, return E_OUTOFMEMORY;
renderer->IMFMediaSink_iface.lpVtbl = &audio_renderer_sink_vtbl; + renderer->IMFMediaSinkPreroll_iface.lpVtbl = &audio_renderer_preroll_vtbl; renderer->refcount = 1; InitializeCriticalSection(&renderer->cs);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69071
Your paranoid android.
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:191:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The win32 Wine build failed
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:191:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The wow32 Wine build failed
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/sar.c | 11 +++++++++-- dlls/mf/tests/mf.c | 13 ++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index 1a00ac4198..d4221cd8a0 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -99,9 +99,16 @@ static ULONG WINAPI audio_renderer_sink_Release(IMFMediaSink *iface)
static HRESULT WINAPI audio_renderer_sink_GetCharacteristics(IMFMediaSink *iface, DWORD *flags) { - FIXME("%p, %p.\n", iface, flags); + struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
- return E_NOTIMPL; + TRACE("%p, %p.\n", iface, flags); + + if (renderer->is_shut_down) + return MF_E_SHUTDOWN; + + *flags = MEDIASINK_FIXED_STREAMS | MEDIASINK_CAN_PREROLL; + + return S_OK; }
static HRESULT WINAPI audio_renderer_sink_AddStreamSink(IMFMediaSink *iface, DWORD stream_sink_id, diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 578c5bcaf7..e278f73ef1 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2639,6 +2639,7 @@ static void test_sar(void) MFCLOCK_STATE state; DWORD flags, count; IMFClock *clock; + IUnknown *unk; HRESULT hr;
hr = CoInitialize(NULL); @@ -2693,6 +2694,14 @@ if (SUCCEEDED(hr)) ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(count == 1, "Unexpected count %u.\n", count);
+ hr = IMFMediaSink_GetCharacteristics(sink, &flags); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(flags == (MEDIASINK_FIXED_STREAMS | MEDIASINK_CAN_PREROLL), "Unexpected flags %#x.\n", flags); + + hr = IMFMediaSink_QueryInterface(sink, &IID_IMFMediaSinkPreroll, (void **)&unk); + ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr); + IUnknown_Release(unk); + /* Shutdown */ hr = IMFMediaSink_Shutdown(sink); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); @@ -2712,6 +2721,9 @@ if (SUCCEEDED(hr)) hr = IMFMediaSink_GetStreamSinkCount(sink, &count); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+ hr = IMFMediaSink_GetCharacteristics(sink, &flags); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + IMFMediaSink_Release(sink);
/* Activation */ @@ -2727,7 +2739,6 @@ if (SUCCEEDED(hr)) IMFMediaSink_Release(sink2);
hr = IMFMediaSink_GetCharacteristics(sink, &flags); -todo_wine ok(hr == S_OK, "Failed to get sink flags, hr %#x.\n", hr);
hr = IMFActivate_ShutdownObject(activate);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69072
Your paranoid android.
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:198:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The win32 Wine build failed
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:198:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The wow32 Wine build failed
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/sar.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/mf/tests/mf.c | 5 +++ 2 files changed, 99 insertions(+)
diff --git a/dlls/mf/sar.c b/dlls/mf/sar.c index d4221cd8a0..eab837b919 100644 --- a/dlls/mf/sar.c +++ b/dlls/mf/sar.c @@ -18,6 +18,7 @@
#define COBJMACROS
+#include "mfapi.h" #include "mfidl.h" #include "mferror.h" #include "mf_private.h" @@ -31,7 +32,9 @@ struct audio_renderer { IMFMediaSink IMFMediaSink_iface; IMFMediaSinkPreroll IMFMediaSinkPreroll_iface; + IMFMediaEventGenerator IMFMediaEventGenerator_iface; LONG refcount; + IMFMediaEventQueue *event_queue; BOOL is_shut_down; CRITICAL_SECTION cs; }; @@ -46,6 +49,11 @@ static struct audio_renderer *impl_from_IMFMediaSinkPreroll(IMFMediaSinkPreroll return CONTAINING_RECORD(iface, struct audio_renderer, IMFMediaSinkPreroll_iface); }
+static struct audio_renderer *impl_from_IMFMediaEventGenerator(IMFMediaEventGenerator *iface) +{ + return CONTAINING_RECORD(iface, struct audio_renderer, IMFMediaEventGenerator_iface); +} + static HRESULT audio_renderer_sink_QueryInterface(IMFMediaSink *iface, REFIID riid, void **obj) { struct audio_renderer *renderer = impl_from_IMFMediaSink(iface); @@ -61,6 +69,10 @@ static HRESULT audio_renderer_sink_QueryInterface(IMFMediaSink *iface, REFIID ri { *obj = &renderer->IMFMediaSinkPreroll_iface; } + else if (IsEqualIID(riid, &IID_IMFMediaEventGenerator)) + { + *obj = &renderer->IMFMediaEventGenerator_iface; + } else { WARN("Unsupported %s.\n", debugstr_guid(riid)); @@ -90,6 +102,8 @@ static ULONG WINAPI audio_renderer_sink_Release(IMFMediaSink *iface)
if (!refcount) { + if (renderer->event_queue) + IMFMediaEventQueue_Release(renderer->event_queue); DeleteCriticalSection(&renderer->cs); heap_free(renderer); } @@ -188,6 +202,7 @@ static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface)
EnterCriticalSection(&renderer->cs); renderer->is_shut_down = TRUE; + IMFMediaEventQueue_Shutdown(renderer->event_queue); LeaveCriticalSection(&renderer->cs);
return S_OK; @@ -242,9 +257,78 @@ static const IMFMediaSinkPrerollVtbl audio_renderer_preroll_vtbl = audio_renderer_preroll_NotifyPreroll, };
+static HRESULT WINAPI audio_renderer_events_QueryInterface(IMFMediaEventGenerator *iface, REFIID riid, void **obj) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + return IMFMediaSink_QueryInterface(&renderer->IMFMediaSink_iface, riid, obj); +} + +static ULONG WINAPI audio_renderer_events_AddRef(IMFMediaEventGenerator *iface) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + return IMFMediaSink_AddRef(&renderer->IMFMediaSink_iface); +} + +static ULONG WINAPI audio_renderer_events_Release(IMFMediaEventGenerator *iface) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + return IMFMediaSink_Release(&renderer->IMFMediaSink_iface); +} + +static HRESULT WINAPI audio_renderer_events_GetEvent(IMFMediaEventGenerator *iface, DWORD flags, IMFMediaEvent **event) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + + TRACE("%p, %#x, %p.\n", iface, flags, event); + + return IMFMediaEventQueue_GetEvent(renderer->event_queue, flags, event); +} + +static HRESULT WINAPI audio_renderer_events_BeginGetEvent(IMFMediaEventGenerator *iface, IMFAsyncCallback *callback, + IUnknown *state) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + + TRACE("%p, %p, %p.\n", iface, callback, state); + + return IMFMediaEventQueue_BeginGetEvent(renderer->event_queue, callback, state); +} + +static HRESULT WINAPI audio_renderer_events_EndGetEvent(IMFMediaEventGenerator *iface, IMFAsyncResult *result, + IMFMediaEvent **event) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + + TRACE("%p, %p, %p.\n", iface, result, event); + + return IMFMediaEventQueue_EndGetEvent(renderer->event_queue, result, event); +} + +static HRESULT WINAPI audio_renderer_events_QueueEvent(IMFMediaEventGenerator *iface, MediaEventType event_type, + REFGUID ext_type, HRESULT hr, const PROPVARIANT *value) +{ + struct audio_renderer *renderer = impl_from_IMFMediaEventGenerator(iface); + + TRACE("%p, %u, %s, %#x, %p.\n", iface, event_type, debugstr_guid(ext_type), hr, value); + + return IMFMediaEventQueue_QueueEventParamVar(renderer->event_queue, event_type, ext_type, hr, value); +} + +static const IMFMediaEventGeneratorVtbl audio_renderer_events_vtbl = +{ + audio_renderer_events_QueryInterface, + audio_renderer_events_AddRef, + audio_renderer_events_Release, + audio_renderer_events_GetEvent, + audio_renderer_events_BeginGetEvent, + audio_renderer_events_EndGetEvent, + audio_renderer_events_QueueEvent, +}; + static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context, IUnknown **obj) { struct audio_renderer *renderer; + HRESULT hr;
TRACE("%p, %p, %p.\n", attributes, user_context, obj);
@@ -253,12 +337,22 @@ static HRESULT sar_create_object(IMFAttributes *attributes, void *user_context,
renderer->IMFMediaSink_iface.lpVtbl = &audio_renderer_sink_vtbl; renderer->IMFMediaSinkPreroll_iface.lpVtbl = &audio_renderer_preroll_vtbl; + renderer->IMFMediaEventGenerator_iface.lpVtbl = &audio_renderer_events_vtbl; renderer->refcount = 1; InitializeCriticalSection(&renderer->cs);
+ if (FAILED(hr = MFCreateEventQueue(&renderer->event_queue))) + goto failed; + *obj = (IUnknown *)&renderer->IMFMediaSink_iface;
return S_OK; + +failed: + + IMFMediaSink_Release(&renderer->IMFMediaSink_iface); + + return hr; }
static void sar_shutdown_object(void *user_context, IUnknown *obj) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index e278f73ef1..fcbbde36fb 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2702,6 +2702,11 @@ if (SUCCEEDED(hr)) ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr); IUnknown_Release(unk);
+ /* Events */ + hr = IMFMediaSink_QueryInterface(sink, &IID_IMFMediaEventGenerator, (void **)&unk); + ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr); + IUnknown_Release(unk); + /* Shutdown */ hr = IMFMediaSink_Shutdown(sink); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69073
Your paranoid android.
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:213:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The win32 Wine build failed
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:213:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The wow32 Wine build failed
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=69069
Your paranoid android.
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:146:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The win32 Wine build failed
=== debiant (build log) ===
../../../wine/dlls/mf/sar.c:146:5: error: initialization of ‘HRESULT (__attribute__((stdcall)) *)(IMFMediaSink *, const IID * const, void **)’ from incompatible pointer type ‘HRESULT (*)(IMFMediaSink *, const IID * const, void **)’ {aka ‘int (*)(struct IMFMediaSink *, const struct _GUID * const, void **)’} [-Werror=incompatible-pointer-types] Task: The wow32 Wine build failed