From 0a62793b7950d5552c1ab5c3c0caca5d5051e17b Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Thu, 28 Apr 2016 13:59:02 +0200 Subject: [PATCH] Backed out changeset df13b449ffcc (bug 1242874) --- dom/audiochannel/AudioChannelAgent.cpp | 21 ++++++++++++++------- dom/audiochannel/nsIAudioChannelAgent.idl | 21 ++++++++------------- dom/fmradio/FMRadio.cpp | 12 ++++-------- dom/html/HTMLMediaElement.cpp | 12 ++++-------- dom/media/webaudio/AudioDestinationNode.cpp | 8 ++++---- dom/media/webspeech/synth/nsSpeechTask.cpp | 18 +++++------------- dom/plugins/base/nsNPAPIPlugin.cpp | 14 ++++---------- dom/telephony/Telephony.cpp | 14 ++++++-------- 8 files changed, 49 insertions(+), 71 deletions(-) diff --git a/dom/audiochannel/AudioChannelAgent.cpp b/dom/audiochannel/AudioChannelAgent.cpp index d61f91859688..4838b9b354f9 100644 --- a/dom/audiochannel/AudioChannelAgent.cpp +++ b/dom/audiochannel/AudioChannelAgent.cpp @@ -201,11 +201,17 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow, return NS_OK; } -NS_IMETHODIMP -AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig) +NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(float *aVolume, + bool* aMuted) { - if (NS_WARN_IF(!aConfig)) { - return NS_ERROR_FAILURE; + MOZ_ASSERT(aVolume); + MOZ_ASSERT(aMuted); + + // Window-less AudioChannelAgents are muted by default. + if (!mWindow) { + *aVolume = 0; + *aMuted = true; + return NS_OK; } RefPtr service = AudioChannelService::GetOrCreate(); @@ -225,13 +231,14 @@ AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig) "mute = %d, volume = %f, suspend = %d\n", this, config.mMuted, config.mVolume, config.mSuspend)); - aConfig->SetConfig(config.mVolume, config.mMuted, config.mSuspend); + *aVolume = config.mVolume; + *aMuted = config.mMuted; + mIsRegToService = true; return NS_OK; } -NS_IMETHODIMP -AudioChannelAgent::NotifyStoppedPlaying() +NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying() { if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR || !mIsRegToService) { diff --git a/dom/audiochannel/nsIAudioChannelAgent.idl b/dom/audiochannel/nsIAudioChannelAgent.idl index ea2fda500a18..dabb7ccd5f52 100644 --- a/dom/audiochannel/nsIAudioChannelAgent.idl +++ b/dom/audiochannel/nsIAudioChannelAgent.idl @@ -55,16 +55,6 @@ interface nsISuspendedTypes : nsISupports const uint32_t SUSPENDED_STOP_DISPOSABLE = 4; }; -%{C++ -namespace mozilla { -namespace dom { -// It's defined in dom/audiochannel/AudioChannelService.h. -class AudioPlaybackConfig; -} -} -%} -[ptr] native AudioPlaybackConfig(mozilla::dom::AudioPlaybackConfig); - [uuid(15c05894-408e-4798-b527-a8c32d9c5f8c)] interface nsIAudioChannelAgentCallback : nsISupports { @@ -162,10 +152,15 @@ interface nsIAudioChannelAgent : nsISupports * Note: Gecko component SHOULD call this function first then start to * play audio stream only when return value is true. * - * @param config - * It contains the playback related states (volume/mute/suspend) + * @return + * normal state: the agent has registered with audio channel service and + * the component should start playback. + * muted state: the agent has registered with audio channel service but + * the component should not start playback. + * faded state: the agent has registered with audio channel service the + * component should start playback as well as reducing the volume. */ - void notifyStartedPlaying(in AudioPlaybackConfig config); + void notifyStartedPlaying(out float volume, out bool muted); /** * Notify the agent we no longer want to play. diff --git a/dom/fmradio/FMRadio.cpp b/dom/fmradio/FMRadio.cpp index ca277927b303..b6250b5e6846 100644 --- a/dom/fmradio/FMRadio.cpp +++ b/dom/fmradio/FMRadio.cpp @@ -452,14 +452,10 @@ FMRadio::EnableAudioChannelAgent() { NS_ENSURE_TRUE_VOID(mAudioChannelAgent); - AudioPlaybackConfig config; - nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - WindowVolumeChanged(config.mVolume, config.mMuted); - WindowSuspendChanged(config.mSuspend); + float volume = 0.0; + bool muted = true; + mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted); + WindowVolumeChanged(volume, muted); mAudioChannelAgentEnabled = true; } diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index a7209c1e89ba..0b035f459ade 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -5061,14 +5061,10 @@ HTMLMediaElement::NotifyAudioChannelAgent(bool aPlaying) AutoNoJSAPI nojsapi; if (aPlaying) { - AudioPlaybackConfig config; - nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - WindowVolumeChanged(config.mVolume, config.mMuted); - WindowSuspendChanged(config.mSuspend); + float volume = 0.0; + bool muted = true; + mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted); + WindowVolumeChanged(volume, muted); } else { mAudioChannelAgent->NotifyStoppedPlaying(); mAudioChannelAgent = nullptr; diff --git a/dom/media/webaudio/AudioDestinationNode.cpp b/dom/media/webaudio/AudioDestinationNode.cpp index 7ea81dcd1410..d9d0ca00de86 100644 --- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -734,14 +734,14 @@ AudioDestinationNode::InputMuted(bool aMuted) return; } - AudioPlaybackConfig config; - nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config); + float volume = 0.0; + bool muted = true; + nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted); if (NS_WARN_IF(NS_FAILED(rv))) { return; } - WindowVolumeChanged(config.mVolume, config.mMuted); - WindowSuspendChanged(config.mSuspend); + WindowVolumeChanged(volume, muted); } } // namespace dom diff --git a/dom/media/webspeech/synth/nsSpeechTask.cpp b/dom/media/webspeech/synth/nsSpeechTask.cpp index f5a66efaa37a..b4574b3b98d6 100644 --- a/dom/media/webspeech/synth/nsSpeechTask.cpp +++ b/dom/media/webspeech/synth/nsSpeechTask.cpp @@ -712,15 +712,9 @@ nsSpeechTask::CreateAudioChannelAgent() mAudioChannelAgent->InitWithWeakCallback(mUtterance->GetOwner(), static_cast(AudioChannelService::GetDefaultAudioChannel()), this); - - AudioPlaybackConfig config; - nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - WindowVolumeChanged(config.mVolume, config.mMuted); - WindowSuspendChanged(config.mSuspend); + float volume = 0.0f; + bool muted = true; + mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted); } void @@ -742,11 +736,9 @@ nsSpeechTask::WindowVolumeChanged(float aVolume, bool aMuted) NS_IMETHODIMP nsSpeechTask::WindowSuspendChanged(nsSuspendedTypes aSuspend) { - if (aSuspend == nsISuspendedTypes::NONE_SUSPENDED && - mUtterance->mPaused) { + if (aSuspend == nsISuspendedTypes::NONE_SUSPENDED) { Resume(); - } else if (aSuspend != nsISuspendedTypes::NONE_SUSPENDED && - !mUtterance->mPaused) { + } else { Pause(); } return NS_OK; diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index d79c39635fd7..da2aee6745a3 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -107,7 +107,6 @@ using mozilla::plugins::PluginModuleContentParent; #endif #include "nsIAudioChannelAgent.h" -#include "AudioChannelService.h" using namespace mozilla; using namespace mozilla::plugins::parent; @@ -2290,19 +2289,14 @@ _setvalue(NPP npp, NPPVariable variable, void *result) return NPERR_NO_ERROR; } } else { - - dom::AudioPlaybackConfig config; - rv = agent->NotifyStartedPlaying(&config); + float volume = 0.0; + bool muted = true; + rv = agent->NotifyStartedPlaying(&volume, &muted); if (NS_WARN_IF(NS_FAILED(rv))) { return NPERR_NO_ERROR; } - rv = inst->WindowVolumeChanged(config.mVolume, config.mMuted); - if (NS_WARN_IF(NS_FAILED(rv))) { - return NPERR_NO_ERROR; - } - - rv = inst->WindowSuspendChanged(config.mSuspend); + rv = inst->WindowVolumeChanged(volume, muted); if (NS_WARN_IF(NS_FAILED(rv))) { return NPERR_NO_ERROR; } diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index a5dc405e4ab9..b293bac64267 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -561,8 +561,9 @@ Telephony::HandleAudioAgentState() } } else if (!activeCall.IsNull() && !mIsAudioStartPlaying) { mIsAudioStartPlaying = true; - AudioPlaybackConfig config; - rv = mAudioAgent->NotifyStartedPlaying(&config); + float volume; + bool muted; + rv = mAudioAgent->NotifyStartedPlaying(&volume, &muted); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -576,12 +577,9 @@ Telephony::HandleAudioAgentState() // because the modem have not changed the call state yet. It causes that // the telephony can't be resumed. Therefore, we don't mute the telephony // at the beginning. - rv = WindowVolumeChanged(1.0, false); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - rv = WindowSuspendChanged(config.mSuspend); + volume = 1.0; + muted = false; + rv = WindowVolumeChanged(volume, muted); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }