diff --git a/dlls/amstream/amstream.c b/dlls/amstream/amstream.c index 0ff29042ba6..7185f5286a0 100644 --- a/dlls/amstream/amstream.c +++ b/dlls/amstream/amstream.c @@ -329,8 +329,29 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream if (!IsEqualGUID(PurposeId, &MSPID_PrimaryVideo) && !IsEqualGUID(PurposeId, &MSPID_PrimaryAudio)) return MS_E_PURPOSEID; - if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo) && (dwFlags & AMMSF_ADDDEFAULTRENDERER)) - return MS_E_PURPOSEID; + if (dwFlags & AMMSF_ADDDEFAULTRENDERER) + { + if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) + { + /* Default renderer not supported by video stream */ + return MS_E_PURPOSEID; + } + else + { + IBaseFilter* dsoundrender_filter; + + /* Create the default renderer for audio */ + hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&dsoundrender_filter); + if (SUCCEEDED(hr)) + { + hr = IGraphBuilder_AddFilter(This->pFilterGraph, dsoundrender_filter, NULL); + IBaseFilter_Release(dsoundrender_filter); + } + + /* No media stream created when the default renderer is used */ + return hr; + } + } hr = mediastream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream); if (SUCCEEDED(hr)) @@ -345,31 +366,6 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream This->pStreams[This->nbStreams] = pStream; This->nbStreams++; - if (dwFlags & AMMSF_ADDDEFAULTRENDERER) - { - if (IsEqualGUID(PurposeId, &MSPID_PrimaryAudio)) - { - IBaseFilter* dsoundrender_filter; - - hr = CoCreateInstance(&CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (LPVOID*)&dsoundrender_filter); - if (SUCCEEDED(hr)) - { - hr = IGraphBuilder_AddFilter(This->pFilterGraph, dsoundrender_filter, NULL); - IBaseFilter_Release(dsoundrender_filter); - } - if (FAILED(hr)) - { - IMediaStream_Release(pStream); - pStream = NULL; - This->nbStreams--; - } - } - else - { - FIXME("Default renderer only supported for audio\n"); - } - } - if (ppNewStream) *ppNewStream = pStream; } diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 6030c233212..234df419187 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -212,7 +212,7 @@ static void test_media_streams(void) hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL); ok((hr == S_OK) || (hr == VFW_E_NO_AUDIO_HARDWARE), "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr); hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryAudio, &audio_stream); - todo_wine ok(hr == MS_E_NOSTREAM, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr); + ok(hr == MS_E_NOSTREAM, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr); /* Verify a stream is created when no default renderer is used */ hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, 0, NULL);