Backed out changeset 98f7e8789561 (bug 923247)
authorEd Morley <emorley@mozilla.com>
Mon, 10 Mar 2014 17:04:04 +0000
changeset 191054 5a49b82e21ee4c786dab0a0f9f5e250d36de5584
parent 191053 0e567df520fd5bc7f1ba8a07c7a010d00423f33b
child 191055 34af3402920baeeb8cba30ca34b9b1577c12f91d
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs923247
milestone30.0a1
backs out98f7e8789561950b7bc99768ccad2291722bf8b1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 98f7e8789561 (bug 923247)
content/html/content/src/HTMLAudioElement.cpp
content/html/content/src/HTMLMediaElement.cpp
content/media/webaudio/AudioContext.cpp
content/media/webaudio/AudioDestinationNode.cpp
content/media/webaudio/AudioDestinationNode.h
dom/audiochannel/AudioChannelAgent.cpp
dom/audiochannel/AudioChannelAgent.h
dom/audiochannel/AudioChannelService.cpp
dom/audiochannel/AudioChannelService.h
dom/audiochannel/nsIAudioChannelAgent.idl
dom/audiochannel/tests/TestAudioChannelService.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsPIDOMWindow.h
dom/base/test/mochitest.ini
dom/base/test/test_audioWindowUtils.html
dom/fmradio/FMRadio.cpp
dom/fmradio/FMRadio.h
dom/interfaces/base/nsIDOMWindowUtils.idl
--- a/content/html/content/src/HTMLAudioElement.cpp
+++ b/content/html/content/src/HTMLAudioElement.cpp
@@ -241,22 +241,16 @@ HTMLAudioElement::CanPlayChanged(int32_t
     SetMutedInternal(mMuted | MUTED_BY_AUDIO_CHANNEL);
   }
 
 #endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
-HTMLAudioElement::WindowVolumeChanged()
-{
-  return HTMLMediaElement::WindowVolumeChanged();
-}
-
-NS_IMETHODIMP
 HTMLAudioElement::Notify(nsITimer* aTimer)
 {
 #ifdef MOZ_B2G
   mTimerActivated = false;
   UpdateAudioChannelPlayingState();
 #endif
   return NS_OK;
 }
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -1724,24 +1724,16 @@ void HTMLMediaElement::SetMutedInternal(
   SetVolumeInternal();
 }
 
 void HTMLMediaElement::SetVolumeInternal()
 {
   float effectiveVolume = mMuted ? 0.0f :
     mAudioChannelFaded ? float(mVolume) * FADED_VOLUME_RATIO : float(mVolume);
 
-  if (mAudioChannelAgent) {
-    float volume;
-    nsresult rv = mAudioChannelAgent->GetWindowVolume(&volume);
-    if (NS_SUCCEEDED(rv)) {
-      effectiveVolume *= volume;
-    }
-  }
-
   if (mDecoder) {
     mDecoder->SetVolume(effectiveVolume);
   } else if (mAudioStream) {
     mAudioStream->SetVolume(effectiveVolume);
   } else if (mSrcStream) {
     GetSrcMediaStream()->SetAudioOutputVolume(this, effectiveVolume);
   }
 }
@@ -3924,22 +3916,16 @@ NS_IMETHODIMP HTMLMediaElement::CanPlayC
 
   NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
 
   UpdateChannelMuteState(static_cast<AudioChannelState>(canPlay));
   mPaused.SetCanPlay(canPlay != AUDIO_CHANNEL_STATE_MUTED);
   return NS_OK;
 }
 
-NS_IMETHODIMP HTMLMediaElement::WindowVolumeChanged()
-{
-  SetVolumeInternal();
-  return NS_OK;
-}
-
 /* readonly attribute TextTrackList textTracks; */
 TextTrackList*
 HTMLMediaElement::TextTracks() const
 {
   return mTextTrackManager ? mTextTrackManager->TextTracks() : nullptr;
 }
 
 already_AddRefed<TextTrack>
--- a/content/media/webaudio/AudioContext.cpp
+++ b/content/media/webaudio/AudioContext.cpp
@@ -59,16 +59,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(AudioContext, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(AudioContext, nsDOMEventTargetHelper)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioContext)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
+static uint8_t gWebAudioOutputKey;
+
 static float GetSampleRateForAudioContext(bool aIsOffline, float aSampleRate)
 {
   if (aIsOffline) {
     return aSampleRate;
   } else {
     AudioStream::InitPreferredSampleRate();
     return static_cast<float>(AudioStream::PreferredSampleRate());
   }
@@ -88,16 +90,17 @@ AudioContext::AudioContext(nsPIDOMWindow
   , mIsShutDown(false)
 {
   aWindow->AddAudioContext(this);
 
   // Note: AudioDestinationNode needs an AudioContext that must already be
   // bound to the window.
   mDestination = new AudioDestinationNode(this, aIsOffline, aNumberOfChannels,
                                           aLength, aSampleRate);
+  mDestination->Stream()->AddAudioOutput(&gWebAudioOutputKey);
   // We skip calling SetIsOnlyNodeForContext during mDestination's constructor,
   // because we can only call SetIsOnlyNodeForContext after mDestination has
   // been set up.
   mDestination->SetIsOnlyNodeForContext(true);
 }
 
 AudioContext::~AudioContext()
 {
--- a/content/media/webaudio/AudioDestinationNode.cpp
+++ b/content/media/webaudio/AudioDestinationNode.cpp
@@ -18,18 +18,16 @@
 #include "nsIScriptObjectPrincipal.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIAppShell.h"
 #include "nsWidgetsCID.h"
 
 namespace mozilla {
 namespace dom {
 
-static uint8_t gWebAudioOutputKey;
-
 class OfflineDestinationNodeEngine : public AudioNodeEngine
 {
 public:
   typedef AutoFallibleTArray<nsAutoArrayPtr<float>, 2> InputChannels;
 
   OfflineDestinationNodeEngine(AudioDestinationNode* aNode,
                                uint32_t aNumberOfChannels,
                                uint32_t aLength,
@@ -230,17 +228,16 @@ AudioDestinationNode::AudioDestinationNo
                             MediaStreamGraph::GetInstance();
   AudioNodeEngine* engine = aIsOffline ?
                             new OfflineDestinationNodeEngine(this, aNumberOfChannels,
                                                              aLength, aSampleRate) :
                             static_cast<AudioNodeEngine*>(new DestinationNodeEngine(this));
 
   mStream = graph->CreateAudioNodeStream(engine, MediaStreamGraph::EXTERNAL_STREAM);
   mStream->AddMainThreadListener(this);
-  mStream->AddAudioOutput(&gWebAudioOutputKey);
 
   if (!aIsOffline && UseAudioChannelService()) {
     nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());
     if (target) {
       target->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"), this,
                                      /* useCapture = */ true,
                                      /* wantsUntrusted = */ false);
     }
@@ -378,33 +375,16 @@ AudioDestinationNode::HandleEvent(nsIDOM
 
 NS_IMETHODIMP
 AudioDestinationNode::CanPlayChanged(int32_t aCanPlay)
 {
   SetCanPlay(aCanPlay == AudioChannelState::AUDIO_CHANNEL_STATE_NORMAL);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-AudioDestinationNode::WindowVolumeChanged()
-{
-  MOZ_ASSERT(mAudioChannelAgent);
-
-  if (!mStream) {
-    return NS_OK;
-  }
-
-  float volume;
-  nsresult rv = mAudioChannelAgent->GetWindowVolume(&volume);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mStream->SetAudioOutputVolume(&gWebAudioOutputKey, volume);
-  return NS_OK;
-}
-
 AudioChannel
 AudioDestinationNode::MozAudioChannelType() const
 {
   return mAudioChannel;
 }
 
 void
 AudioDestinationNode::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv)
--- a/content/media/webaudio/AudioDestinationNode.h
+++ b/content/media/webaudio/AudioDestinationNode.h
@@ -33,17 +33,16 @@ public:
                        uint32_t aNumberOfChannels = 0,
                        uint32_t aLength = 0,
                        float aSampleRate = 0.0f);
 
   virtual void DestroyMediaStream() MOZ_OVERRIDE;
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioDestinationNode, AudioNode)
-  NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual uint16_t NumberOfOutputs() const MOZ_FINAL MOZ_OVERRIDE
   {
     return 0;
   }
@@ -57,16 +56,19 @@ public:
 
   void StartRendering();
 
   void OfflineShutdown();
 
   // nsIDOMEventListener
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
 
+  // nsIAudioChannelAgentCallback
+  NS_IMETHOD CanPlayChanged(int32_t aCanPlay);
+
   AudioChannel MozAudioChannelType() const;
   void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
 
   virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
   void FireOfflineCompletionEvent();
 
   // An amount that should be added to the MediaStream's current time to
   // get the AudioContext.currentTime.
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -1,17 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "AudioChannelAgent.h"
 #include "AudioChannelCommon.h"
 #include "AudioChannelService.h"
 #include "nsIDOMWindow.h"
-#include "nsPIDOMWindow.h"
 #include "nsXULAppAPI.h"
 
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_2(AudioChannelAgent, mWindow, mCallback)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AudioChannelAgent)
   NS_INTERFACE_MAP_ENTRY(nsIAudioChannelAgent)
@@ -179,34 +178,8 @@ already_AddRefed<nsIAudioChannelAgentCal
 AudioChannelAgent::GetCallback()
 {
   nsCOMPtr<nsIAudioChannelAgentCallback> callback = mCallback;
   if (!callback) {
     callback = do_QueryReferent(mWeakCallback);
   }
   return callback.forget();
 }
-
-void
-AudioChannelAgent::WindowVolumeChanged()
-{
-  nsCOMPtr<nsIAudioChannelAgentCallback> callback = GetCallback();
-  if (!callback) {
-    return;
-  }
-
-  callback->WindowVolumeChanged();
-}
-
-NS_IMETHODIMP
-AudioChannelAgent::GetWindowVolume(float* aVolume)
-{
-  NS_ENSURE_ARG_POINTER(aVolume);
-
-  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(mWindow);
-  if (!win) {
-    *aVolume = 1.0f;
-    return NS_OK;
-  }
-
-  *aVolume = win->GetAudioGlobalVolume();
-  return NS_OK;
-}
--- a/dom/audiochannel/AudioChannelAgent.h
+++ b/dom/audiochannel/AudioChannelAgent.h
@@ -29,23 +29,16 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIAUDIOCHANNELAGENT
 
   NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgent)
 
   AudioChannelAgent();
   virtual void NotifyAudioChannelStateChanged();
 
-  void WindowVolumeChanged();
-
-  nsIDOMWindow* Window() const
-  {
-    return mWindow;
-  }
-
 private:
   virtual ~AudioChannelAgent();
 
   // Returns mCallback if that's non-null, or otherwise tries to get an
   // nsIAudioChannelAgentCallback out of mWeakCallback.
   already_AddRefed<nsIAudioChannelAgentCallback> GetCallback();
 
   nsresult InitInternal(nsIDOMWindow* aWindow, int32_t aAudioAgentType,
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -775,49 +775,8 @@ AudioChannelService::GetInternalType(Aud
 
     case AUDIO_CHANNEL_LAST:
     default:
       break;
   }
 
   MOZ_CRASH("unexpected audio channel type");
 }
-
-struct RefreshAgentsVolumeData
-{
-  RefreshAgentsVolumeData(nsPIDOMWindow* aWindow)
-    : mWindow(aWindow)
-  {}
-
-  nsPIDOMWindow* mWindow;
-  nsTArray<nsRefPtr<AudioChannelAgent>> mAgents;
-};
-
-PLDHashOperator
-AudioChannelService::RefreshAgentsVolumeEnumerator(AudioChannelAgent* aAgent,
-                                                   AudioChannelAgentData* aUnused,
-                                                   void* aPtr)
-{
-  MOZ_ASSERT(aAgent);
-  RefreshAgentsVolumeData* data = static_cast<RefreshAgentsVolumeData*>(aPtr);
-  MOZ_ASSERT(data);
-
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aAgent->Window());
-  if (window && !window->IsInnerWindow()) {
-    window = window->GetCurrentInnerWindow();
-  }
-
-  if (window == data->mWindow) {
-    data->mAgents.AppendElement(aAgent);
-  }
-
-  return PL_DHASH_NEXT;
-}
-void
-AudioChannelService::RefreshAgentsVolume(nsPIDOMWindow* aWindow)
-{
-  RefreshAgentsVolumeData data(aWindow);
-  mAgents.EnumerateRead(RefreshAgentsVolumeEnumerator, &data);
-
-  for (uint32_t i = 0; i < data.mAgents.Length(); ++i) {
-    data.mAgents[i]->WindowVolumeChanged();
-  }
-}
--- a/dom/audiochannel/AudioChannelService.h
+++ b/dom/audiochannel/AudioChannelService.h
@@ -11,18 +11,16 @@
 #include "nsIObserver.h"
 #include "nsTArray.h"
 #include "nsITimer.h"
 
 #include "AudioChannelCommon.h"
 #include "AudioChannelAgent.h"
 #include "nsClassHashtable.h"
 
-class nsPIDOMWindow;
-
 namespace mozilla {
 namespace dom {
 #ifdef MOZ_WIDGET_GONK
 class SpeakerManagerService;
 #endif
 class AudioChannelService
 : public nsIObserver
 , public nsITimerCallback
@@ -82,18 +80,16 @@ public:
    * AudioChannelManager calls this function to notify the default channel used
    * to adjust volume when there is no any active channel.
    */
   virtual void SetDefaultVolumeControlChannel(AudioChannelType aType,
                                               bool aHidden);
 
   bool AnyAudioChannelIsActive();
 
-  void RefreshAgentsVolume(nsPIDOMWindow* aWindow);
-
 #ifdef MOZ_WIDGET_GONK
   void RegisterSpeakerManager(SpeakerManagerService* aSpeakerManager)
   {
     if (!mSpeakerManager.Contains(aSpeakerManager)) {
       mSpeakerManager.AppendElement(aSpeakerManager);
     }
   }
 
@@ -178,21 +174,16 @@ protected:
     AudioChannelState mState;
     const bool mWithVideo;
   };
 
   static PLDHashOperator
   NotifyEnumerator(AudioChannelAgent* aAgent,
                    AudioChannelAgentData* aData, void *aUnused);
 
-  static PLDHashOperator
-  RefreshAgentsVolumeEnumerator(AudioChannelAgent* aAgent,
-                                AudioChannelAgentData* aUnused,
-                                void *aPtr);
-
   nsClassHashtable< nsPtrHashKey<AudioChannelAgent>, AudioChannelAgentData > mAgents;
 #ifdef MOZ_WIDGET_GONK
   nsTArray<SpeakerManagerService*>  mSpeakerManager;
 #endif
   nsTArray<uint64_t> mChannelCounters[AUDIO_CHANNEL_INT_LAST];
 
   AudioChannelType mCurrentHigherChannel;
   AudioChannelType mCurrentVisibleHigherChannel;
--- a/dom/audiochannel/nsIAudioChannelAgent.idl
+++ b/dom/audiochannel/nsIAudioChannelAgent.idl
@@ -1,51 +1,46 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIDOMWindow;
 
-[scriptable, uuid(194b55d9-39c0-45c6-b8ef-b8049f978ea5)]
+[function, scriptable, uuid(86975108-cd78-4796-8fc8-6cd777cd6eba)]
 interface nsIAudioChannelAgentCallback : nsISupports
 {
   /**
    * Notified when the playable status of channel is changed.
    *
    * @param canPlay
    *        Callback from agent to notify component of the playable status
    *        of the channel. If canPlay is muted state, component SHOULD stop
    *        playing media associated with this channel as soon as possible. if
    *        it is faded state then the volume of media should be reduced.
    */
   void canPlayChanged(in long canPlay);
-
-  /**
-   * Notified when the window volume/mute is changed
-   */
-  void windowVolumeChanged();
 };
 
 /**
  * This interface provides an agent for gecko components to participate
  * in the audio channel service. Gecko components are responsible for
  *   1. Indicating what channel type they are using (via the init() member
  *      function).
  *   2. Before playing, checking the playable status of the channel.
  *   3. Notifying the agent when they start/stop using this channel.
  *   4. Notifying the agent of changes to the visibility of the component using
  *      this channel.
  *
  * The agent will invoke a callback to notify Gecko components of
  *   1. Changes to the playable status of this channel.
  */
 
-[scriptable, uuid(2b0222a5-8f7b-49d2-9ab8-cd01b744b23e)]
+[scriptable, uuid(86ef883d-9cec-4c04-994f-5de198286e7c)]
 interface nsIAudioChannelAgent : nsISupports
 {
   const long AUDIO_AGENT_CHANNEL_NORMAL             = 0;
   const long AUDIO_AGENT_CHANNEL_CONTENT            = 1;
   const long AUDIO_AGENT_CHANNEL_NOTIFICATION       = 2;
   const long AUDIO_AGENT_CHANNEL_ALARM              = 3;
   const long AUDIO_AGENT_CHANNEL_TELEPHONY          = 4;
   const long AUDIO_AGENT_CHANNEL_RINGER             = 5;
@@ -128,15 +123,10 @@ interface nsIAudioChannelAgent : nsISupp
   void stopPlaying();
 
   /**
    * Notify the agent of the visibility state of the window using this agent.
    * @param visible
    *    True if the window associated with the agent is visible.
    */
   void setVisibilityState(in boolean visible);
-
-  /**
-   * Retrieve the volume from the window.
-   */
-  readonly attribute float windowVolume;
 };
 
--- a/dom/audiochannel/tests/TestAudioChannelService.cpp
+++ b/dom/audiochannel/tests/TestAudioChannelService.cpp
@@ -99,21 +99,16 @@ public:
 
   NS_IMETHODIMP CanPlayChanged(int32_t canPlay)
   {
     mCanPlay = static_cast<AudioChannelState>(canPlay);
     mWaitCallback = false;
     return NS_OK;
   }
 
-  NS_IMETHODIMP WindowVolumeChanged()
-  {
-    return NS_OK;
-  }
-
   nsresult GetCanPlay(AudioChannelState *_ret)
   {
     int loop = 0;
     while (mWaitCallback) {
       #ifdef XP_WIN
       Sleep(1000);
       #else
       sleep(1);
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3727,58 +3727,8 @@ nsDOMWindowUtils::GetOMTAOrComputedStyle
   nsCOMPtr<nsIDOMCSSStyleDeclaration> style;
   rv = element->GetCurrentDoc()->GetWindow()->
     GetComputedStyle(aElement, aProperty, getter_AddRefs(style));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return style->GetPropertyValue(aProperty, aResult);
 }
 
-NS_IMETHODIMP
-nsDOMWindowUtils::GetAudioMuted(bool* aMuted)
-{
-  if (!nsContentUtils::IsCallerChrome()) {
-    return NS_ERROR_DOM_SECURITY_ERR;
-  }
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
-  NS_ENSURE_STATE(window);
-
-  *aMuted = window->GetAudioMuted();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::SetAudioMuted(bool aMuted)
-{
-  if (!nsContentUtils::IsCallerChrome()) {
-    return NS_ERROR_DOM_SECURITY_ERR;
-  }
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
-  NS_ENSURE_STATE(window);
-
-  window->SetAudioMuted(aMuted);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::GetAudioVolume(float* aVolume)
-{
-  if (!nsContentUtils::IsCallerChrome()) {
-    return NS_ERROR_DOM_SECURITY_ERR;
-  }
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
-  NS_ENSURE_STATE(window);
-
-  *aVolume = window->GetAudioVolume();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::SetAudioVolume(float aVolume)
-{
-  if (!nsContentUtils::IsCallerChrome()) {
-    return NS_ERROR_DOM_SECURITY_ERR;
-  }
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
-  NS_ENSURE_STATE(window);
-
-  return window->SetAudioVolume(aVolume);
-}
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -55,17 +55,16 @@
 #include "nsContentCID.h"
 #include "nsLayoutStatics.h"
 #include "nsCCUncollectableMarker.h"
 #include "mozilla/dom/workers/Workers.h"
 #include "nsJSPrincipals.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Debug.h"
 #include "mozilla/MouseEvents.h"
-#include "AudioChannelService.h"
 
 // Interfaces Needed
 #include "nsIFrame.h"
 #include "nsCanvasFrame.h"
 #include "nsIWidget.h"
 #include "nsIWidgetListener.h"
 #include "nsIBaseWindow.h"
 #include "nsIDeviceSensors.h"
@@ -560,17 +559,16 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWind
 : mFrameElement(nullptr), mDocShell(nullptr), mModalStateDepth(0),
   mRunningTimeout(nullptr), mMutationBits(0), mIsDocumentLoaded(false),
   mIsHandlingResizeEvent(false), mIsInnerWindow(aOuterWindow != nullptr),
   mMayHavePaintEventListener(false), mMayHaveTouchEventListener(false),
   mMayHaveMouseEnterLeaveEventListener(false),
   mMayHavePointerEnterLeaveEventListener(false),
   mIsModalContentWindow(false),
   mIsActive(false), mIsBackground(false),
-  mAudioMuted(false), mAudioVolume(1.0),
   mInnerWindow(nullptr), mOuterWindow(aOuterWindow),
   // Make sure no actual window ends up with mWindowID == 0
   mWindowID(++gNextWindowID), mHasNotifiedGlobalCreated(false),
   mMarkedCCGeneration(0)
  {}
 
 nsPIDOMWindow::~nsPIDOMWindow() {}
 
@@ -3579,110 +3577,16 @@ nsPIDOMWindow::CreatePerformanceObjectIf
       !timingEnabled) {
     timedChannel = nullptr;
   }
   if (timing) {
     mPerformance = new nsPerformance(this, timing, timedChannel);
   }
 }
 
-bool
-nsPIDOMWindow::GetAudioMuted() const
-{
-  if (!IsInnerWindow()) {
-    return mInnerWindow->GetAudioMuted();
-  }
-
-  return mAudioMuted;
-}
-
-void
-nsPIDOMWindow::SetAudioMuted(bool aMuted)
-{
-  if (!IsInnerWindow()) {
-    mInnerWindow->SetAudioMuted(aMuted);
-    return;
-  }
-
-  if (mAudioMuted == aMuted) {
-    return;
-  }
-
-  mAudioMuted = aMuted;
-  RefreshMediaElements();
-}
-
-float
-nsPIDOMWindow::GetAudioVolume() const
-{
-  if (!IsInnerWindow()) {
-    return mInnerWindow->GetAudioVolume();
-  }
-
-  return mAudioVolume;
-}
-
-nsresult
-nsPIDOMWindow::SetAudioVolume(float aVolume)
-{
-  if (!IsInnerWindow()) {
-    return mInnerWindow->SetAudioVolume(aVolume);
-  }
-
-  if (aVolume < 0.0) {
-    return NS_ERROR_DOM_INDEX_SIZE_ERR;
-  }
-
-  if (mAudioVolume == aVolume) {
-    return NS_OK;
-  }
-
-  mAudioVolume = aVolume;
-  RefreshMediaElements();
-  return NS_OK;
-}
-
-float
-nsPIDOMWindow::GetAudioGlobalVolume()
-{
-  float globalVolume = 1.0;
-  nsCOMPtr<nsPIDOMWindow> window = this;
-
-  do {
-    if (window->GetAudioMuted()) {
-      return 0;
-    }
-
-    globalVolume *= window->GetAudioVolume();
-
-    nsCOMPtr<nsIDOMWindow> win;
-    window->GetParent(getter_AddRefs(win));
-    if (window == win) {
-      break;
-    }
-
-    window = do_QueryInterface(win);
-
-    // If there is not parent, or we are the toplevel or the volume is
-    // already 0.0, we don't continue.
-  } while (window && window != this && globalVolume);
-
-  return globalVolume;
-}
-
-void
-nsPIDOMWindow::RefreshMediaElements()
-{
-  nsRefPtr<AudioChannelService> service =
-    AudioChannelService::GetAudioChannelService();
-  if (service) {
-    service->RefreshAgentsVolume(this);
-  }
-}
-
 // nsISpeechSynthesisGetter
 
 #ifdef MOZ_WEBSPEECH
 SpeechSynthesis*
 nsGlobalWindow::GetSpeechSynthesis(ErrorResult& aError)
 {
   FORWARD_TO_INNER_OR_THROW(GetSpeechSynthesis, (aError), aError, nullptr);
 
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -185,33 +185,21 @@ public:
     if (!mDoc) {
       MaybeCreateDoc();
     }
     return mDoc;
   }
 
   virtual NS_HIDDEN_(bool) IsRunningTimeout() = 0;
 
-  // Audio API
-  bool GetAudioMuted() const;
-  void SetAudioMuted(bool aMuted);
-
-  float GetAudioVolume() const;
-  nsresult SetAudioVolume(float aVolume);
-
-  float GetAudioGlobalVolume();
-
 protected:
   // Lazily instantiate an about:blank document if necessary, and if
   // we have what it takes to do so.
   void MaybeCreateDoc();
 
-  float GetAudioGlobalVolumeInternal(float aVolume);
-  void RefreshMediaElements();
-
 public:
   // Internal getter/setter for the frame element, this version of the
   // getter crosses chrome boundaries whereas the public scriptable
   // one doesn't for security reasons.
   mozilla::dom::Element* GetFrameElementInternal() const;
   void SetFrameElementInternal(mozilla::dom::Element* aFrameElement);
 
   bool IsLoadingOrRunningTimeout() const
@@ -775,19 +763,16 @@ protected:
   // Only used on outer windows.
   bool                   mIsActive;
 
   // Tracks whether our docshell is active.  If it is, mIsBackground
   // is false.  Too bad we have so many different concepts of
   // "active".  Only used on outer windows.
   bool                   mIsBackground;
 
-  bool                   mAudioMuted;
-  float                  mAudioVolume;
-
   // And these are the references between inner and outer windows.
   nsPIDOMWindow         *mInnerWindow;
   nsCOMPtr<nsPIDOMWindow> mOuterWindow;
 
   // the element within the document that is currently focused when this
   // window is active
   nsCOMPtr<nsIContent> mFocusedNode;
 
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -3,17 +3,16 @@ support-files =
   iframe_messageChannel_cloning.html
   iframe_messageChannel_pingpong.html
   iframe_messageChannel_post.html
   file_empty.html
   iframe_postMessage_solidus.html
 
 [test_Image_constructor.html]
 [test_appname_override.html]
-[test_audioWindowUtils.html]
 [test_bug913761.html]
 [test_bug978522.html]
 [test_bug979109.html]
 [test_clearTimeoutIntervalNoArg.html]
 [test_consoleEmptyStack.html]
 [test_constructor-assignment.html]
 [test_constructor.html]
 [test_document.all_unqualified.html]
deleted file mode 100644
--- a/dom/base/test/test_audioWindowUtils.html
+++ /dev/null
@@ -1,92 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for audio controller in windows</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<iframe src="about:blank" id="iframe"></iframe>
-<script type="application/javascript">
-
-function runTest() {
-  var utils = SpecialPowers.wrap(window).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
-  ok(utils, "nsIDOMWindowUtils");
-
-  is(utils.audioMuted, false, "By default utils.audioMuted is false");
-  utils.audioMuted = true;
-  is(utils.audioMuted, true, "utils.audioMuted is true");
-  utils.audioMuted = false;
-  is(utils.audioMuted, false, "utils.audioMuted is true");
-
-  is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
-  utils.audioVolume = 0.4;
-  is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
-  utils.audioMuted = true;
-  is(utils.audioMuted, true, "utils.audioMuted is true");
-  is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
-  utils.audioMuted = false;
-
-  utils.audioVolume = 2.0;
-  is(utils.audioVolume, 2.0, "utils.audioVolume is ok");
-
-  try {
-    utils.audioVolume = -42;
-    ok(false, "This should throw");
-  } catch(e) {
-    ok(true, "This should throw");
-  }
-
-  utils.audioVolume = 0;
-  is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
-  utils.audioVolume = 1.0;
-  is(utils.audioVolume, 1.0, "utils.audioVolume is ok");
-
-  var iframe = document.getElementById("iframe");
-  ok(iframe, "IFrame exists");
-
-  utils = SpecialPowers.wrap(iframe.contentWindow).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
-  ok(utils, "nsIDOMWindowUtils");
-
-  is(utils.audioMuted, false, "By default utils.audioMuted is false");
-  utils.audioMuted = true;
-  is(utils.audioMuted, true, "utils.audioMuted is true");
-  utils.audioMuted = false;
-  is(utils.audioMuted, false, "utils.audioMuted is true");
-
-  is(utils.audioVolume, 1.0, "By default utils.audioVolume is 1.0");
-  utils.audioVolume = 0.4;
-  is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
-  utils.audioMuted = true;
-  is(utils.audioMuted, true, "utils.audioMuted is true");
-  is(utils.audioVolume.toFixed(2), 0.4, "utils.audioVolume is ok");
-  utils.audioMuted = false;
-
-  utils.audioVolume = 2.0;
-  is(utils.audioVolume, 2.0, "utils.audioVolume is ok");
-
-  try {
-    utils.audioVolume = -42;
-    ok(false, "This should throw");
-  } catch(e) {
-    ok(true, "This should throw");
-  }
-
-  utils.audioVolume = 0;
-  is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
-  utils.audioVolume = 1.0;
-  is(utils.audioVolume, 1.0, "utils.audioVolume is ok");
-
-  SimpleTest.finish();
-}
-
-SpecialPowers.pushPrefEnv({ "set": [["media.useAudioChannelService", true]]}, runTest);
-SimpleTest.waitForExplicitFinish();
-
-</script>
-</body>
-</html>
--- a/dom/fmradio/FMRadio.cpp
+++ b/dom/fmradio/FMRadio.cpp
@@ -384,22 +384,16 @@ FMRadio::EnableAudioChannelAgent()
 
 NS_IMETHODIMP
 FMRadio::CanPlayChanged(int32_t aCanPlay)
 {
   SetCanPlay(aCanPlay == AudioChannelState::AUDIO_CHANNEL_STATE_NORMAL);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-FMRadio::WindowVolumeChanged(float aVolume)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 void
 FMRadio::SetCanPlay(bool aCanPlay)
 {
   IFMRadioService::Singleton()->EnableAudio(aCanPlay);
 }
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FMRadio)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
--- a/dom/fmradio/FMRadio.h
+++ b/dom/fmradio/FMRadio.h
@@ -29,17 +29,16 @@ class FMRadio MOZ_FINAL : public nsDOMEv
 
 {
   friend class FMRadioRequest;
 
 public:
   FMRadio();
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
 
   void Init(nsPIDOMWindow *aWindow);
   void Shutdown();
 
   /* hal::SwitchObserver */
   virtual void Notify(const hal::SwitchEvent& aEvent) MOZ_OVERRIDE;
@@ -78,16 +77,19 @@ public:
 
   already_AddRefed<DOMRequest> CancelSeek();
 
   IMPL_EVENT_HANDLER(enabled);
   IMPL_EVENT_HANDLER(disabled);
   IMPL_EVENT_HANDLER(antennaavailablechange);
   IMPL_EVENT_HANDLER(frequencychange);
 
+  // nsIAudioChannelAgentCallback
+  NS_IMETHOD CanPlayChanged(int32_t aCanPlay);
+
   // nsIDOMEventListener
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
 
 private:
   ~FMRadio();
 
   void SetCanPlay(bool aCanPlay);
   void EnableAudioChannelAgent();
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -38,17 +38,17 @@ interface nsIDOMFile;
 interface nsIFile;
 interface nsIDOMTouch;
 interface nsIDOMClientRect;
 interface nsIURI;
 interface nsIDOMEventTarget;
 interface nsIRunnable;
 interface nsICompositionStringSynthesizer;
 
-[scriptable, uuid(ef70a299-033c-4adc-b214-6649aed9d828)]
+[scriptable, uuid(27efada9-b8ea-4d70-a2e6-f46b9ba905f4)]
 interface nsIDOMWindowUtils : nsISupports {
 
   /**
    * Image animation mode of the window. When this attribute's value
    * is changed, the implementation should set all images in the window
    * to the given value. That is, when set to kDontAnimMode, all images
    * will stop animating. The attribute's value must be one of the
    * animationMode values from imgIContainer.
@@ -1577,22 +1577,9 @@ interface nsIDOMWindowUtils : nsISupport
 
    /*
     * Returns the value of a given property.  If the property is animated off
     * the main thread, this function will fetch the correct value from the
     * compositor.
     */
    AString getOMTAOrComputedStyle(in nsIDOMElement aElement,
                                   in AString aProperty);
-
-   /**
-    * With this it's possible to mute all the MediaElements in this window.
-    * We have audioMuted and audioVolume to preserve the volume across
-    * mute/umute.
-    */
-   attribute boolean audioMuted;
-
-    /**
-     * range: greater or equal to 0. The real volume level is affected by the
-     * volume of all ancestor windows.
-     */
-    attribute float audioVolume;
 };