Commit 5764c7d5 authored by Nick Alexander's avatar Nick Alexander
Browse files

Bug 1753603 - Don't `{Start,Stop}AudioSession` in background tasks. r=mossop

The presenting issue is that each background task's audio session is
user-visible via various Windows UIs that display "volume controls" or
"volume mixers"; this avoids that.

Differential Revision: https://phabricator.services.mozilla.com/D141101
parent 9b68a45e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -5941,7 +5941,15 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
  mScopedXPCOM = nullptr;

#if defined(XP_WIN)
  bool wantAudio = true;
#  ifdef MOZ_BACKGROUNDTASKS
  if (BackgroundTasks::IsBackgroundTaskMode()) {
    wantAudio = false;
  }
#  endif
  if (MOZ_LIKELY(wantAudio)) {
    mozilla::widget::StopAudioSession();
  }
#endif

  // unlock the profile after ScopedXPCOMStartup object (xpcom)
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ LOCAL_INCLUDES += [

DEFINES["MOZ_UNICODE"] = True

for var in "MOZ_ENABLE_D3D10_LAYER":
for var in ("MOZ_ENABLE_D3D10_LAYER", "MOZ_BACKGROUNDTASKS"):
    if CONFIG[var]:
        DEFINES[var] = True

+10 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "WinIMEHandler.h"
#include "mozilla/widget/AudioSession.h"
#include "mozilla/BackgroundHangMonitor.h"
#include "mozilla/BackgroundTasks.h"
#include "mozilla/Hal.h"
#include "nsIDOMWakeLockListener.h"
#include "nsIPowerManagerService.h"
@@ -591,8 +592,16 @@ nsAppShell::Run(void) {
  // Note StopAudioSession() is called from nsAppRunner.cpp after xpcom is torn
  // down to insure the browser shuts down after child processes.
  if (XRE_IsParentProcess()) {
    bool wantAudio = true;
#ifdef MOZ_BACKGROUNDTASKS
    if (BackgroundTasks::IsBackgroundTaskMode()) {
      wantAudio = false;
    }
#endif
    if (MOZ_LIKELY(wantAudio)) {
      mozilla::widget::StartAudioSession();
    }
  }

  // Add an observer that disables the screen saver when requested by Gecko.
  // For example when we're playing video in the foreground tab. Whole firefox