summaryrefslogtreecommitdiffstats
path: root/src/plugins/wmf/player/mfplayersession.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-03-04 17:22:47 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-07 15:12:13 +0100
commit7d894ca0aabc054d0575139351937987f015e450 (patch)
tree30a13e22058f8d5ece219621b7839e2a050deba0 /src/plugins/wmf/player/mfplayersession.cpp
parenta07530d6061edbec703ab0590eca103a787068e8 (diff)
WMF: each media player now has its own volume.
Instead of setting the volume on the audio session, which is shared by all QMediaPlayers, we now set the volume on the media player's own audio stream. This results in all QMediaPlayers correctly having independent volumes. [ChangeLog][QtMultimedia][Windows] QMediaPlayer::setVolume() does not affect the volume of other QMediaPlayers anymore. Task-number: QTBUG-30317 Change-Id: I8ea8ec47fc86127da01dc5c8247fb6f72c834630 Reviewed-by: Wouter Huysentruit <wouter_huysentruit@hotmail.com> Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src/plugins/wmf/player/mfplayersession.cpp')
-rw-r--r--src/plugins/wmf/player/mfplayersession.cpp50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/plugins/wmf/player/mfplayersession.cpp b/src/plugins/wmf/player/mfplayersession.cpp
index 183f0231d..69958061b 100644
--- a/src/plugins/wmf/player/mfplayersession.cpp
+++ b/src/plugins/wmf/player/mfplayersession.cpp
@@ -1325,8 +1325,10 @@ void MFPlayerSession::setVolume(int volume)
if (m_volume == volume)
return;
m_volume = volume;
- if (m_volumeControl)
- m_volumeControl->SetMasterVolume(m_volume * 0.01f);
+
+ if (!m_muted)
+ setVolumeInternal(volume);
+
emit volumeChanged(m_volume);
}
@@ -1340,11 +1342,26 @@ void MFPlayerSession::setMuted(bool muted)
if (m_muted == muted)
return;
m_muted = muted;
- if (m_volumeControl)
- m_volumeControl->SetMute(BOOL(m_muted));
+
+ setVolumeInternal(muted ? 0 : m_volume);
+
emit mutedChanged(m_muted);
}
+void MFPlayerSession::setVolumeInternal(int volume)
+{
+ if (m_volumeControl) {
+ quint32 channelCount = 0;
+ if (!SUCCEEDED(m_volumeControl->GetChannelCount(&channelCount))
+ || channelCount == 0)
+ return;
+
+ float scaled = volume * 0.01f;
+ for (quint32 i = 0; i < channelCount; ++i)
+ m_volumeControl->SetChannelVolume(i, scaled);
+ }
+}
+
int MFPlayerSession::bufferStatus()
{
if (!m_netsourceStatistics)
@@ -1570,10 +1587,8 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
}
}
- if (SUCCEEDED(MFGetService(m_session, MR_POLICY_VOLUME_SERVICE, IID_PPV_ARGS(&m_volumeControl)))) {
- m_volumeControl->SetMasterVolume(m_volume * 0.01f);
- m_volumeControl->SetMute(m_muted);
- }
+ if (SUCCEEDED(MFGetService(m_session, MR_STREAM_VOLUME_SERVICE, IID_PPV_ARGS(&m_volumeControl))))
+ setVolumeInternal(m_muted ? 0 : m_volume);
DWORD dwCharacteristics = 0;
m_sourceResolver->mediaSource()->GetCharacteristics(&dwCharacteristics);
@@ -1619,25 +1634,6 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
break;
case MEEndOfPresentationSegment:
break;
- case MEAudioSessionVolumeChanged:
- if (m_volumeControl) {
- float currentVolume = 1;
- if (SUCCEEDED(m_volumeControl->GetMasterVolume(&currentVolume))) {
- int scaledVolume = currentVolume * 100;
- if (scaledVolume != m_volume) {
- m_volume = scaledVolume;
- emit volumeChanged(scaledVolume);
- }
- }
- BOOL currentMuted = FALSE;
- if (SUCCEEDED(m_volumeControl->GetMute(&currentMuted))) {
- if (currentMuted != BOOL(m_muted)) {
- m_muted = bool(currentMuted);
- emit mutedChanged(m_muted);
- }
- }
- }
- break;
case MESessionTopologyStatus: {
UINT32 status;
if (SUCCEEDED(sessionEvent->GetUINT32(MF_EVENT_TOPOLOGY_STATUS, &status))) {