Bug 1480036 - Allow scaling all MSG volume with a pref. r=pehrsons
authorPaul Adenot <paul@paul.cx>
Wed, 01 Aug 2018 12:10:32 +0200
changeset 487681 f2dc5d8ac9ac55899c14d7a031951ccef0bc720d
parent 487680 352e47aeafac716617392486f88c20107dce2a00
child 487682 8695f16b39ed48f002dccabf249da238bdb3e8b4
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1480036
milestone63.0a1
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
Bug 1480036 - Allow scaling all MSG volume with a pref. r=pehrsons Differential Revision: https://phabricator.services.mozilla.com/D2594
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraphImpl.h
dom/media/tests/mochitest/head.js
testing/mochitest/runtests.py
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -676,17 +676,17 @@ MediaStreamGraphImpl::CreateOrDestroyAud
 StreamTime
 MediaStreamGraphImpl::PlayAudio(MediaStream* aStream)
 {
   MOZ_ASSERT(OnGraphThread());
   MOZ_ASSERT(mRealtime, "Should only attempt to play audio in realtime mode");
 
   float volume = 0.0f;
   for (uint32_t i = 0; i < aStream->mAudioOutputs.Length(); ++i) {
-    volume += aStream->mAudioOutputs[i].mVolume;
+    volume += aStream->mAudioOutputs[i].mVolume * mGlobalVolume;
   }
 
   StreamTime ticksWritten = 0;
 
   for (uint32_t i = 0; i < aStream->mAudioOutputStreams.Length(); ++i) {
     ticksWritten = 0;
 
     MediaStream::AudioOutputStream& audioOutput = aStream->mAudioOutputStreams[i];
@@ -3706,16 +3706,17 @@ MediaStreamGraphImpl::MediaStreamGraphIm
   , mPostedRunInStableState(false)
   , mRealtime(aDriverRequested != OFFLINE_THREAD_DRIVER)
   , mNonRealtimeProcessing(false)
   , mStreamOrderDirty(false)
   , mLatencyLog(AsyncLatencyLogger::Get())
   , mAbstractMainThread(aMainThread)
   , mSelfRef(this)
   , mOutputChannels(std::min<uint32_t>(8, CubebUtils::MaxNumberOfChannels()))
+  , mGlobalVolume(CubebUtils::GetVolumeScale())
 #ifdef DEBUG
   , mCanRunMessagesSynchronously(false)
 #endif
 {
   if (mRealtime) {
     if (aDriverRequested == AUDIO_THREAD_DRIVER) {
       // Always start with zero input channels.
       mDriver = new AudioCallbackDriver(this, 0);
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -917,16 +917,22 @@ private:
    */
   nsTArray<WindowAndStream> mWindowCaptureStreams;
 
   /**
    * Number of channels on output.
    */
   const uint32_t mOutputChannels;
 
+  /**
+   * Global volume scale. Used when running tests so that the output is not too
+   * loud.
+   */
+  const float mGlobalVolume;
+
 #ifdef DEBUG
   /**
    * Used to assert when AppendMessage() runs ControlMessages synchronously.
    */
   bool mCanRunMessagesSynchronously;
 #endif
 };
 
--- a/dom/media/tests/mochitest/head.js
+++ b/dom/media/tests/mochitest/head.js
@@ -421,22 +421,16 @@ function setupEnvironment() {
       ['media.getusermedia.audiocapture.enabled', true],
       ['media.getusermedia.screensharing.enabled', true],
       ['media.getusermedia.window.focus_source.enabled', false],
       ['media.recorder.audio_node.enabled', true],
       ['media.webaudio.audiocontextoptions-samplerate.enabled', true]
     ]
   };
 
-  if (!WANT_FAKE_AUDIO) {
-    defaultMochitestPrefs.set.push(
-      ["media.volume_scale", "1"],
-    );
-  }
-
   const isAndroid = !!navigator.userAgent.includes("Android");
 
   if (isAndroid) {
     defaultMochitestPrefs.set.push(
       ["media.navigator.video.default_width", 320],
       ["media.navigator.video.default_height", 240],
       ["media.navigator.video.max_fr", 10],
       ["media.autoplay.default", Ci.nsIAutoplay.ALLOWED]
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1922,16 +1922,17 @@ toolbar#nav-bar {
         if getattr(self, 'testRootAbs', None):
             prefs['mochitest.testRoot'] = self.testRootAbs
 
         # See if we should use fake media devices.
         if options.useTestMediaDevices:
             prefs['media.audio_loopback_dev'] = self.mediaDevices['audio']
             prefs['media.video_loopback_dev'] = self.mediaDevices['video']
             prefs['media.cubeb.output_device'] = "Null Output"
+            prefs['media.volume_scale'] = "1.0"
 
         # Disable web replay rewinding by default if recordings are being saved.
         if options.recordingPath:
             prefs["devtools.recordreplay.enableRewinding"] = False
 
         self.profile.set_preferences(prefs)
 
         # Extra prefs from --setpref