Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/tests/mf.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 789b4d0494..6c44e4728e 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2798,15 +2798,58 @@ if (SUCCEEDED(hr)) hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
+ hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype); + ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr); + hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype2); ok(hr == S_OK, "Failed to get media type, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype2, NULL); ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
+ IMFMediaType_Release(mediatype); + + hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype2); + ok(hr == S_OK, "Failed to set current type, hr %#x.\n", hr); + + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(mediatype == mediatype2, "Unexpected instance.\n"); + IMFMediaType_Release(mediatype); + + IMFMediaType_Release(mediatype2); + + /* Set partial type. */ + hr = MFCreateMediaType(&mediatype); + ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr); + + hr = IMFMediaType_GetGUID(mediatype2, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr); + + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); + + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr); + + hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype); + ok(hr == S_OK, "Failed to set current type, hr %#x.\n", hr); + + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(mediatype == mediatype2, "Unexpected instance.\n"); IMFMediaType_Release(mediatype2); + + hr = IMFMediaType_GetCount(mediatype, &count); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(count == 2, "Unexpected attribute count %u.\n", count); + IMFMediaType_Release(mediatype);
+ /* Reset back to uninitialized state. */ + hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + IMFMediaTypeHandler_Release(handler); } IMFStreamSink_Release(stream_sink);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index debb58de4d..47431c4968 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -1240,6 +1240,7 @@ static HRESULT session_set_current_topology(struct media_session *session, IMFTo
static void session_set_topology(struct media_session *session, DWORD flags, IMFTopology *topology) { + IMFTopology *resolved_topology = NULL; HRESULT hr = S_OK;
/* Resolve unless claimed to be full. */ @@ -1247,8 +1248,6 @@ static void session_set_topology(struct media_session *session, DWORD flags, IMF { if (!(flags & MFSESSION_SETTOPOLOGY_NORESOLUTION)) { - IMFTopology *resolved_topology = NULL; - hr = session_bind_output_nodes(topology);
if (SUCCEEDED(hr)) @@ -1286,27 +1285,27 @@ static void session_set_topology(struct media_session *session, DWORD flags, IMF /* With no current topology set it right away, otherwise queue. */ if (topology) { - if (session->presentation.topo_status == MF_TOPOSTATUS_INVALID) - { - hr = session_set_current_topology(session, topology); - } - else + struct queued_topology *queued_topology; + + if ((queued_topology = heap_alloc_zero(sizeof(*queued_topology)))) { - struct queued_topology *queued_topology; + queued_topology->topology = topology; + IMFTopology_AddRef(queued_topology->topology);
- if ((queued_topology = heap_alloc_zero(sizeof(*queued_topology)))) - { - queued_topology->topology = topology; - IMFTopology_AddRef(queued_topology->topology); + list_add_tail(&session->topologies, &queued_topology->entry); + }
- list_add_tail(&session->topologies, &queued_topology->entry); - } + if (session->presentation.topo_status == MF_TOPOSTATUS_INVALID) + { + hr = session_set_current_topology(session, topology); + session_set_topo_status(session, hr, MF_TOPOSTATUS_READY); } }
- session_set_topo_status(session, hr, MF_TOPOSTATUS_READY); - LeaveCriticalSection(&session->cs); + + if (resolved_topology) + IMFTopology_Release(resolved_topology); }
static HRESULT WINAPI mfsession_QueryInterface(IMFMediaSession *iface, REFIID riid, void **out)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/session.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 47431c4968..5b9f720815 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -539,10 +539,18 @@ static void session_set_topo_status(struct media_session *session, HRESULT statu if (topo_status == MF_TOPOSTATUS_INVALID) return;
+ if (list_empty(&session->topologies)) + { + FIXME("Unexpectedly empty topology queue.\n"); + return; + } + if (topo_status > session->presentation.topo_status) { + struct queued_topology *topology = LIST_ENTRY(list_head(&session->topologies), struct queued_topology, entry); + param.vt = VT_UNKNOWN; - param.punkVal = (IUnknown *)session->presentation.current_topology; + param.punkVal = (IUnknown *)topology->topology;
if (FAILED(MFCreateMediaEvent(MESessionTopologyStatus, &GUID_NULL, status, ¶m, &event))) return;