Commit f6a5a3d0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf/sar: Use advertised type in IsMediaTypeSupported().

parent 57e30f27
......@@ -1479,11 +1479,10 @@ static HRESULT WINAPI audio_renderer_stream_type_handler_IsMediaTypeSupported(IM
TRACE("%p, %p, %p.\n", iface, in_type, out_type);
EnterCriticalSection(&renderer->cs);
hr = renderer->current_media_type && IMFMediaType_IsEqual(renderer->current_media_type, in_type, &flags) == S_OK ?
S_OK : MF_E_INVALIDMEDIATYPE;
hr = IMFMediaType_IsEqual(renderer->media_type, in_type, &flags);
LeaveCriticalSection(&renderer->cs);
return hr;
return hr != S_OK ? MF_E_INVALIDMEDIATYPE : hr;
}
static HRESULT WINAPI audio_renderer_stream_type_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
......
......@@ -2831,7 +2831,7 @@ static void test_sar(void)
IMFMediaSink *sink, *sink2;
IMFStreamSink *stream_sink;
IMFAttributes *attributes;
DWORD id, flags, count;
DWORD i, id, flags, count;
IMFActivate *activate;
MFCLOCK_STATE state;
IMFClock *clock;
......@@ -2839,6 +2839,7 @@ static void test_sar(void)
HRESULT hr;
GUID guid;
BOOL mute;
int found;
hr = CoInitialize(NULL);
ok(hr == S_OK, "Failed to initialize, hr %#x.\n", hr);
......@@ -2988,6 +2989,22 @@ todo_wine
ok(hr == S_OK, "Failed to get type count, hr %#x.\n", hr);
ok(!!count, "Unexpected type count %u.\n", count);
/* A number of same major/subtype entries are returned, with different degrees of finer format
details. Some incomplete types are not accepted, check that at least one of them is considered supported. */
for (i = 0, found = -1; i < count; ++i)
{
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, i, &mediatype);
ok(hr == S_OK, "Failed to get media type, hr %#x.\n", hr);
if (SUCCEEDED(IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL)))
found = i;
IMFMediaType_Release(mediatype);
if (found != -1) break;
}
ok(found != -1, "Haven't found a supported type.\n");
hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype);
ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
......@@ -3005,16 +3022,16 @@ todo_wine
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, mediatype);
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype2);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, found, &mediatype2);
ok(hr == S_OK, "Failed to get media type, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype3);
hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, found, &mediatype3);
ok(hr == S_OK, "Failed to get media type, hr %#x.\n", hr);
ok(mediatype2 == mediatype3, "Unexpected instance.\n");
IMFMediaType_Release(mediatype3);
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype2, NULL);
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
IMFMediaType_Release(mediatype);
......@@ -3026,39 +3043,8 @@ todo_wine
ok(mediatype == mediatype2, "Unexpected instance.\n");
IMFMediaType_Release(mediatype);
/* Type is validated against current type. */
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype2, NULL);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
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);
......@@ -3121,10 +3107,8 @@ todo_wine
IMFAudioStreamVolume_Release(stream_volume);
hr = MFGetService((IUnknown *)sink, &MR_AUDIO_POLICY_SERVICE, &IID_IMFAudioPolicy, (void **)&unk);
todo_wine
ok(hr == MF_E_NOT_INITIALIZED, "Failed to get interface, hr %#x.\n", hr);
if (SUCCEEDED(hr))
IUnknown_Release(unk);
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
IUnknown_Release(unk);
/* Shutdown */
EXPECT_REF(present_clock, 2);
......
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