Bug 1531833 - Expose a way to set a global "communication mode" in CubebUtils, to be use by real-time duplex audio users. r=pehrsons
☠☠ backed out by e8de4ced5bb4 ☠ ☠
authorPaul Adenot <paul@paul.cx>
Thu, 11 Apr 2019 09:19:34 +0000
changeset 468962 74ad8e7a722b22087d4a122be3c4f9eb50a04092
parent 468961 b1268e5f702363fba0ca10c31ddac05a9e89c8da
child 468963 e725253ee97629bbed151cb7ba9c9ed0278f9921
push id35855
push useraciure@mozilla.com
push dateThu, 11 Apr 2019 16:11:15 +0000
treeherdermozilla-central@c77962add953 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1531833
milestone68.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 1531833 - Expose a way to set a global "communication mode" in CubebUtils, to be use by real-time duplex audio users. r=pehrsons Differential Revision: https://phabricator.services.mozilla.com/D21736
dom/media/CubebUtils.cpp
dom/media/CubebUtils.h
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -304,16 +304,22 @@ cubeb* GetCubebContext() {
 
 // This is only exported when running tests.
 void ForceSetCubebContext(cubeb* aCubebContext) {
   StaticMutexAutoLock lock(sMutex);
   sCubebContext = aCubebContext;
   sCubebState = CubebState::Initialized;
 }
 
+void SetInCommunication(bool aInCommunication) {
+#ifdef MOZ_WIDGET_ANDROID
+  java::GeckoAppShell::SetCommunicationAudioModeOn(aInCommunication);
+#endif
+}
+
 bool InitPreferredSampleRate() {
   StaticMutexAutoLock lock(sMutex);
   if (sPreferredSampleRate != 0) {
     return true;
   }
 #ifdef MOZ_WIDGET_ANDROID
   sPreferredSampleRate = AndroidGetAudioOutputSampleRate();
 #else
--- a/dom/media/CubebUtils.h
+++ b/dom/media/CubebUtils.h
@@ -40,16 +40,20 @@ cubeb* GetCubebContext();
 void ReportCubebStreamInitFailure(bool aIsFirstStream);
 void ReportCubebBackendUsed();
 uint32_t GetCubebPlaybackLatencyInMilliseconds();
 uint32_t GetCubebMSGLatencyInFrames(cubeb_stream_params* params);
 bool CubebLatencyPrefSet();
 void GetCurrentBackend(nsAString& aBackend);
 cubeb_stream_prefs GetDefaultStreamPrefs();
 char* GetForcedOutputDevice();
+// No-op on all platforms but Android, where it tells the device's AudioManager
+// to switch to "communication mode", which might change audio routing,
+// bluetooth communication type, etc.
+void SetInCommunication(bool aInCommunication);
 
 #  ifdef MOZ_WIDGET_ANDROID
 uint32_t AndroidGetAudioOutputSampleRate();
 uint32_t AndroidGetAudioOutputFramesPerBuffer();
 #  endif
 
 #  ifdef ENABLE_SET_CUBEB_BACKEND
 void ForceSetCubebContext(cubeb* aCubebContext);