diff options
author | André de la Rocha <andre.rocha@qt.io> | 2022-10-21 20:21:34 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-10-27 15:58:56 +0000 |
commit | d8facde757e238b01649aef9c1944a0cb3631c5f (patch) | |
tree | 787a1b18776dc187c1d70396067c48027e418eb7 | |
parent | 174e96a12948061596e1cee43822a5760cc87325 (diff) |
Windows: do not add audio output to topology when there is no output device
Otherwise videos with audio fail to play when there is no audio output
device, instead of just playing the video without audio.
Fixes: QTBUG-107205
Change-Id: Ie296023251e3b7c019e63ca09dc68663230aa013
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit d1e3cb9034bf0ebf45b55082217580f4b4a2b790)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/multimedia/windows/player/mfplayersession.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/plugins/multimedia/windows/player/mfplayersession.cpp b/src/plugins/multimedia/windows/player/mfplayersession.cpp index da6bd432b..58efaa87e 100644 --- a/src/plugins/multimedia/windows/player/mfplayersession.cpp +++ b/src/plugins/multimedia/windows/player/mfplayersession.cpp @@ -468,20 +468,15 @@ IMFTopologyNode* MFPlayerSession::addOutputNode(MediaType mediaType, IMFTopology } auto id = m_audioOutput->device.id(); - if (!id.isEmpty()) { - QString s = QString::fromUtf8(id); - hr = activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, (LPCWSTR)s.utf16()); - } else { - //This is the default one that has been inserted in updateEndpoints(), - //so give the activate a hint that we want to use the device for multimedia playback - //then the media foundation will choose an appropriate one. - - //from MSDN: - //The ERole enumeration defines constants that indicate the role that the system has assigned to an audio endpoint device. - //eMultimedia: Music, movies, narration, and live music recording. - hr = activate->SetUINT32(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ROLE, eMultimedia); + if (id.isEmpty()) { + qWarning() << "No audio output"; + activate->Release(); + node->Release(); + return NULL; } + QString s = QString::fromUtf8(id); + hr = activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, (LPCWSTR)s.utf16()); if (FAILED(hr)) { qWarning() << "Failed to set attribute for audio device" << m_audioOutput->device.description(); activate->Release(); |