diff options
author | André de la Rocha <andre.rocha@qt.io> | 2022-10-21 20:21:34 +0200 |
---|---|---|
committer | André de la Rocha <andre.rocha@qt.io> | 2022-10-27 22:36:25 +0200 |
commit | 27d8a5bdf9a7c433f20b87958bc26580ba92533d (patch) | |
tree | 4c5293b348bb7a5bf9d51fe7d7494693a4ac9c0a | |
parent | 8c8f1fd73e35d27a739c41aae50e3496d1d49890 (diff) | |
download | qtmultimedia-27d8a5bdf9a7c433f20b87958bc26580ba92533d.tar.gz |
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: André de la Rocha <andre.rocha@qt.io>
-rw-r--r-- | src/multimedia/platform/windows/player/mfplayersession.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/multimedia/platform/windows/player/mfplayersession.cpp b/src/multimedia/platform/windows/player/mfplayersession.cpp index 85ffcd8d5..54d581c99 100644 --- a/src/multimedia/platform/windows/player/mfplayersession.cpp +++ b/src/multimedia/platform/windows/player/mfplayersession.cpp @@ -503,20 +503,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(); |