From 94905a3054295f48b570c0fa2a7bfeada080b9d4 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 27 May 2013 17:13:05 +1200 Subject: [PATCH] Bug 876133. Ensure output audio volume is updated when 'volume' attribute is set on media element. r=cpearce --HG-- extra : rebase_source : defbb7d13b70349d321006db37f005888fb6a79e --- content/html/content/public/HTMLMediaElement.h | 5 +++++ content/html/content/src/HTMLMediaElement.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/content/html/content/public/HTMLMediaElement.h b/content/html/content/public/HTMLMediaElement.h index 3d91c0afcdd..889a77859e6 100644 --- a/content/html/content/public/HTMLMediaElement.h +++ b/content/html/content/public/HTMLMediaElement.h @@ -796,6 +796,11 @@ protected: * Mute or unmute the audio and change the value that the |muted| map. */ void SetMutedInternal(uint32_t aMuted); + /** + * Update the volume of the output audio stream to match the element's + * current mMuted/mVolume state. + */ + void SetVolumeInternal(); /** * Suspend (if aPauseForInactiveDocument) or resume element playback and diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index 4ef7c937332..eb6d852b877 100644 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -1509,7 +1509,7 @@ HTMLMediaElement::SetVolume(double aVolume, ErrorResult& aRv) mVolume = aVolume; // Here we want just to update the volume. - SetMutedInternal(mMuted); + SetVolumeInternal(); DispatchAsyncEvent(NS_LITERAL_STRING("volumechange")); } @@ -1687,6 +1687,11 @@ void HTMLMediaElement::SetMutedInternal(uint32_t aMuted) return; } + SetVolumeInternal(); +} + +void HTMLMediaElement::SetVolumeInternal() +{ float effectiveVolume = mMuted ? 0.0f : float(mVolume); if (mDecoder) {