Skip to content

Commit

Permalink
Bug 1617283 - Shifted AudioSession to MTA and removed COM violations …
Browse files Browse the repository at this point in the history
…r=handyman

Cleans up the interface to AudioSession and brings in line with COM best practices.  Uses background threads that are implicitly MTA and asserts proper thread behavior.  This also removes AudioSession's Co[Un]Initialize static analysis violations.

Differential Revision: https://phabricator.services.mozilla.com/D140741
  • Loading branch information
Shazib Summar committed Apr 7, 2022
1 parent 49f86db commit 20cb0cd
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 189 deletions.
1 change: 0 additions & 1 deletion build/win32/orderfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6180,7 +6180,6 @@ XPCOMService_GetSocketTransportService
?BroadcastStringBundle@ContentParent@dom@mozilla@@SAXABVStringBundleDescriptor@23@@Z
?Get@SharedStringMap@ipc@dom@mozilla@@QAE_NABV?$nsTString@D@@AAV?$nsTSubstring@_S@@@Z
?ReinitForContent@ImageBridgeChild@layers@mozilla@@SA_N$$QAV?$Endpoint@VPImageBridgeChild@layers@mozilla@@@ipc@3@I@Z
?RecvAudioSessionData@widget@mozilla@@YA?AW4nsresult@@ABUnsID@@ABV?$nsTString@_S@@1@Z
?Release@WakeLock@dom@mozilla@@UAGKXZ
?GetInstance@PowerManagerService@power@dom@mozilla@@SA?AU?$already_AddRefed@VPowerManagerService@power@dom@mozilla@@@@XZ
?RegisterWakeLockObserver@hal@mozilla@@YAXPAV?$Observer@VWakeLockInformation@hal@mozilla@@@2@@Z
Expand Down
1 change: 0 additions & 1 deletion build/win64/orderfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6464,7 +6464,6 @@ ZN11encoding_rs3mem17utf16_valid_up_to17h89dc8b8f218f8fa1E
?BroadcastStringBundle@ContentParent@dom@mozilla@@SAXAEBVStringBundleDescriptor@23@@Z
?Get@SharedStringMap@ipc@dom@mozilla@@QEAA_NAEBV?$nsTString@D@@AEAV?$nsTSubstring@_S@@@Z
?GetAndResetReleaseFence@RenderCompositor@wr@mozilla@@UEAA?AVFileDescriptor@ipc@3@XZ
?RecvAudioSessionData@widget@mozilla@@YA?AW4nsresult@@AEBUnsID@@AEBV?$nsTString@_S@@1@Z
?Release@WakeLock@dom@mozilla@@UEAAKXZ
?GetInstance@PowerManagerService@power@dom@mozilla@@SA?AU?$already_AddRefed@VPowerManagerService@power@dom@mozilla@@@@XZ
?RegisterWakeLockObserver@hal@mozilla@@YAXPEAV?$Observer@VWakeLockInformation@hal@mozilla@@@2@@Z
Expand Down
5 changes: 0 additions & 5 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@
# include <process.h>
# define getpid _getpid
# include "mozilla/WinDllServices.h"
# include "mozilla/widget/AudioSession.h"
# include "mozilla/widget/WinContentSystemParameters.h"
#endif

Expand Down Expand Up @@ -3092,10 +3091,6 @@ void ContentChild::ShutdownInternal() {
os->NotifyObservers(ToSupports(this), "content-child-shutdown", nullptr);
}

#if defined(XP_WIN)
mozilla::widget::StopAudioSession();
#endif

GetIPCChannel()->SetAbortOnError(false);

if (mProfilerController) {
Expand Down
24 changes: 12 additions & 12 deletions toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5922,6 +5922,18 @@ int XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) {
// run!
rv = XRE_mainRun();

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

#ifdef MOZ_INSTRUMENT_EVENT_LOOP
mozilla::ShutdownEventTracing();
#endif
Expand All @@ -5939,18 +5951,6 @@ 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)
// has gone out of scope. see bug #386739 for more details
mProfileLock->Unlock();
Expand Down
1 change: 0 additions & 1 deletion tools/lint/mscom-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ forbid-mscom-init:
- toolkit/crashreporter/google-breakpad/src/common/windows/pdb_source_line_writer.cc
- toolkit/mozapps/defaultagent/main.cpp
- uriloader/exthandler/win/nsOSHelperAppService.cpp
- widget/windows/AudioSession.cpp
- widget/windows/InkCollector.cpp
- widget/windows/TaskbarPreview.cpp
- widget/windows/WinTaskbar.cpp
Expand Down
Loading

0 comments on commit 20cb0cd

Please sign in to comment.