Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 29 +++++++++++++++++++++++++-- dlls/mf/tests/mf.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 36e0c901d80..94454cd2f2a 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -331,6 +331,7 @@ struct quality_manager IMFClockStateSink IMFClockStateSink_iface; LONG refcount;
+ IMFTopology *topology; IMFPresentationClock *clock; unsigned int state; CRITICAL_SECTION cs; @@ -4802,6 +4803,8 @@ static ULONG WINAPI standard_quality_manager_Release(IMFQualityManager *iface) { if (manager->clock) IMFPresentationClock_Release(manager->clock); + if (manager->topology) + IMFTopology_Release(manager->topology); DeleteCriticalSection(&manager->cs); heap_free(manager); } @@ -4809,11 +4812,32 @@ static ULONG WINAPI standard_quality_manager_Release(IMFQualityManager *iface) return refcount; }
+static void standard_quality_manager_set_topology(struct quality_manager *manager, IMFTopology *topology) +{ + if (manager->topology) + IMFTopology_Release(manager->topology); + manager->topology = topology; + if (manager->topology) + IMFTopology_AddRef(manager->topology); +} + static HRESULT WINAPI standard_quality_manager_NotifyTopology(IMFQualityManager *iface, IMFTopology *topology) { - FIXME("%p, %p stub.\n", iface, topology); + struct quality_manager *manager = impl_from_IMFQualityManager(iface); + HRESULT hr = S_OK;
- return S_OK; + TRACE("%p, %p.\n", iface, topology); + + EnterCriticalSection(&manager->cs); + if (manager->state == QUALITY_MANAGER_SHUT_DOWN) + hr = MF_E_SHUTDOWN; + else + { + standard_quality_manager_set_topology(manager, topology); + } + LeaveCriticalSection(&manager->cs); + + return hr; }
static void standard_quality_manager_release_clock(struct quality_manager *manager) @@ -4886,6 +4910,7 @@ static HRESULT WINAPI standard_quality_manager_Shutdown(IMFQualityManager *iface if (manager->state != QUALITY_MANAGER_SHUT_DOWN) { standard_quality_manager_release_clock(manager); + standard_quality_manager_set_topology(manager, NULL); manager->state = QUALITY_MANAGER_SHUT_DOWN; } LeaveCriticalSection(&manager->cs); diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index ba313adc15c..9bbf82c97e7 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -3649,6 +3649,7 @@ static void test_quality_manager(void) { IMFPresentationClock *clock; IMFQualityManager *manager; + IMFTopology *topology; HRESULT hr;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); @@ -3666,6 +3667,9 @@ static void test_quality_manager(void) hr = IMFQualityManager_NotifyPresentationClock(manager, NULL); ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
+ hr = IMFQualityManager_NotifyTopology(manager, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + /* Set clock, then shutdown. */ EXPECT_REF(clock, 1); EXPECT_REF(manager, 1); @@ -3681,6 +3685,9 @@ static void test_quality_manager(void) hr = IMFQualityManager_NotifyPresentationClock(manager, clock); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+ hr = IMFQualityManager_NotifyTopology(manager, NULL); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + hr = IMFQualityManager_NotifyPresentationClock(manager, NULL); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
@@ -3703,6 +3710,48 @@ static void test_quality_manager(void)
IMFPresentationClock_Release(clock);
+ /* Set topology. */ + hr = MFCreateStandardQualityManager(&manager); + ok(hr == S_OK, "Failed to create quality manager, hr %#x.\n", hr); + + hr = MFCreateTopology(&topology); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + EXPECT_REF(topology, 1); + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + EXPECT_REF(topology, 2); + + hr = IMFQualityManager_NotifyTopology(manager, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + EXPECT_REF(topology, 1); + + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + EXPECT_REF(topology, 2); + hr = IMFQualityManager_Shutdown(manager); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + EXPECT_REF(topology, 1); + + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); + + IMFQualityManager_Release(manager); + + hr = MFCreateStandardQualityManager(&manager); + ok(hr == S_OK, "Failed to create quality manager, hr %#x.\n", hr); + + EXPECT_REF(topology, 1); + hr = IMFQualityManager_NotifyTopology(manager, topology); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + EXPECT_REF(topology, 2); + + IMFQualityManager_Release(manager); + EXPECT_REF(topology, 1); + + IMFTopology_Release(topology); + hr = MFShutdown(); ok(hr == S_OK, "Shutdown failure, hr %#x.\n", hr); }