Backed out 6 changesets (bug 1531833) for geckoview failures on PermissionDelegateTest.media CLOSED TREE
authorOana Pop Rus <opoprus@mozilla.com>
Thu, 11 Apr 2019 21:16:55 +0300
changeset 469046 e8de4ced5bb43d0ef7a481faf94d9d2bdcce584a
parent 469045 55c2f04c1751ae9d237646cb114b2533b86fc026
child 469047 ef120e802c6f59c8e8d58c58659e857c888767d6
push id35856
push usercsabou@mozilla.com
push dateFri, 12 Apr 2019 03:19:48 +0000
treeherdermozilla-central@940684cd1065 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1531833
milestone68.0a1
backs outf90ad6bb8ebdc2469a75d7792d8c18df0204b9d9
465570a54b46a7edd02b0e327c5cde7353dbf224
e725253ee97629bbed151cb7ba9c9ed0278f9921
74ad8e7a722b22087d4a122be3c4f9eb50a04092
b1268e5f702363fba0ca10c31ddac05a9e89c8da
e3ec78b2db1f8a4a8877ccd4abb911615848f694
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 6 changesets (bug 1531833) for geckoview failures on PermissionDelegateTest.media CLOSED TREE Backed out changeset f90ad6bb8ebd (bug 1531833) Backed out changeset 465570a54b46 (bug 1531833) Backed out changeset e725253ee976 (bug 1531833) Backed out changeset 74ad8e7a722b (bug 1531833) Backed out changeset b1268e5f7023 (bug 1531833) Backed out changeset e3ec78b2db1f (bug 1531833)
dom/media/CubebUtils.cpp
dom/media/CubebUtils.h
dom/media/GraphDriver.cpp
dom/media/GraphDriver.h
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraph.h
dom/media/MediaStreamGraphImpl.h
dom/media/webrtc/MediaEngineWebRTC.cpp
dom/media/webrtc/MediaEngineWebRTCAudio.h
media/libcubeb/disable-device-switching.patch
media/libcubeb/include/cubeb.h
media/libcubeb/moz.yaml
media/libcubeb/src/android/sles_definitions.h
media/libcubeb/src/cubeb_audiounit.cpp
media/libcubeb/src/cubeb_opensl.c
media/libcubeb/src/cubeb_wasapi.cpp
mobile/android/geckoview/src/main/AndroidManifest.xml
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -142,24 +142,16 @@ bool sCubebDisableDeviceSwitching = true
 #ifdef MOZ_CUBEB_REMOTING
 bool sCubebSandbox = false;
 size_t sAudioIPCPoolSize;
 size_t sAudioIPCStackSize;
 #endif
 StaticAutoPtr<char> sBrandName;
 StaticAutoPtr<char> sCubebBackendName;
 StaticAutoPtr<char> sCubebOutputDeviceName;
-#ifdef MOZ_WIDGET_ANDROID
-// Counts the number of time a request for switching to global "communication
-// mode" has been received. If this is > 0, global communication mode is to be
-// enabled. If it is 0, the global communication mode is to be disabled.
-// This allows to correctly track the global behaviour to adopt accross
-// asynchronous GraphDriver changes, on Android.
-int sInCommunicationCount = 0;
-#endif
 
 const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties";
 
 const char* AUDIOSTREAM_BACKEND_ID_STR[] = {
     "jack",  "pulse",       "alsa",  "audiounit", "audioqueue", "wasapi",
     "winmm", "directsound", "sndio", "opensl",    "audiotrack", "kai"};
 /* Index for failures to create an audio stream the first time. */
 const int CUBEB_BACKEND_INIT_FAILURE_FIRST =
@@ -312,34 +304,16 @@ 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
-  StaticMutexAutoLock lock(sMutex);
-  if (aInCommunication) {
-    sInCommunicationCount++;
-  } else {
-    MOZ_ASSERT(sInCommunicationCount > 0);
-    sInCommunicationCount--;
-  }
-
-  if (sInCommunicationCount == 1) {
-    java::GeckoAppShell::SetCommunicationAudioModeOn(true);
-  } else if (sInCommunicationCount == 0) {
-    java::GeckoAppShell::SetCommunicationAudioModeOn(false);
-  }
-#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
@@ -8,18 +8,16 @@
 #  define CubebUtils_h_
 
 #  include "cubeb/cubeb.h"
 #  include "nsString.h"
 #  include "mozilla/RefPtr.h"
 
 class AudioDeviceInfo;
 
-MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(cubeb_stream_prefs)
-
 namespace mozilla {
 namespace CubebUtils {
 
 typedef cubeb_devid AudioDeviceID;
 
 // Initialize Audio Library. Some Audio backends require initializing the
 // library before using it.
 void InitLibrary();
@@ -42,20 +40,16 @@ 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);
--- a/dom/media/GraphDriver.cpp
+++ b/dom/media/GraphDriver.cpp
@@ -464,18 +464,17 @@ StreamAndPromiseForOperation::StreamAndP
     MediaStream* aStream, void* aPromise, dom::AudioContextOperation aOperation,
     dom::AudioContextOperationFlags aFlags)
     : mStream(aStream),
       mPromise(aPromise),
       mOperation(aOperation),
       mFlags(aFlags) {}
 
 AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl,
-                                         uint32_t aInputChannelCount,
-                                         AudioInputType aAudioInputType)
+                                         uint32_t aInputChannelCount)
     : GraphDriver(aGraphImpl),
       mOutputChannels(0),
       mSampleRate(0),
       mInputChannelCount(aInputChannelCount),
       mIterationDurationMS(MEDIA_GRAPH_TARGET_PERIOD_MS),
       mStarted(false),
       mInitShutdownThread(
           SharedThreadPool::Get(NS_LITERAL_CSTRING("CubebOperation"), 1)),
@@ -490,36 +489,26 @@ AudioCallbackDriver::AudioCallbackDriver
   mInitShutdownThread->SetIdleThreadTimeout(
       PR_MillisecondsToInterval(kIdleThreadTimeoutMs));
 
 #if defined(XP_WIN)
   if (XRE_IsContentProcess()) {
     audio::AudioNotificationReceiver::Register(this);
   }
 #endif
-  if (aAudioInputType == AudioInputType::Voice) {
-    LOG(LogLevel::Debug, ("VOICE."));
-    mInputDevicePreference = CUBEB_DEVICE_PREF_VOICE;
-    CubebUtils::SetInCommunication(true);
-  } else {
-    mInputDevicePreference = CUBEB_DEVICE_PREF_ALL;
-  }
 }
 
 AudioCallbackDriver::~AudioCallbackDriver() {
   MOZ_ASSERT(mPromisesForOperation.IsEmpty());
   MOZ_ASSERT(!mAddedMixer);
 #if defined(XP_WIN)
   if (XRE_IsContentProcess()) {
     audio::AudioNotificationReceiver::Unregister(this);
   }
 #endif
-  if (mInputDevicePreference == CUBEB_DEVICE_PREF_VOICE) {
-    CubebUtils::SetInCommunication(false);
-  }
 }
 
 bool IsMacbookOrMacbookAir() {
 #ifdef XP_MACOSX
   size_t len = 0;
   sysctlbyname("hw.model", NULL, &len, NULL, 0);
   if (len) {
     UniquePtr<char[]> model(new char[len]);
@@ -595,19 +584,16 @@ bool AudioCallbackDriver::Init() {
 
   mBuffer = AudioCallbackBufferWrapper<AudioDataValue>(mOutputChannels);
   mScratchBuffer =
       SpillBuffer<AudioDataValue, WEBAUDIO_BLOCK_SIZE * 2>(mOutputChannels);
 
   output.channels = mOutputChannels;
   output.layout = CUBEB_LAYOUT_UNDEFINED;
   output.prefs = CubebUtils::GetDefaultStreamPrefs();
-  if (mInputDevicePreference == CUBEB_DEVICE_PREF_VOICE) {
-    output.prefs |= static_cast<cubeb_stream_prefs>(CUBEB_STREAM_PREF_VOICE);
-  }
 
   uint32_t latency_frames = CubebUtils::GetCubebMSGLatencyInFrames(&output);
 
   // Macbook and MacBook air don't have enough CPU to run very low latency
   // MediaStreamGraphs, cap the minimal latency to 512 frames int this case.
   if (IsMacbookOrMacbookAir()) {
     latency_frames = std::max((uint32_t)512, latency_frames);
   }
--- a/dom/media/GraphDriver.h
+++ b/dom/media/GraphDriver.h
@@ -318,17 +318,16 @@ struct StreamAndPromiseForOperation {
                                dom::AudioContextOperationFlags aFlags);
   RefPtr<MediaStream> mStream;
   void* mPromise;
   dom::AudioContextOperation mOperation;
   dom::AudioContextOperationFlags mFlags;
 };
 
 enum AsyncCubebOperation { INIT, SHUTDOWN };
-enum class AudioInputType { Unknown, Voice };
 
 /**
  * This is a graph driver that is based on callback functions called by the
  * audio api. This ensures minimal audio latency, because it means there is no
  * buffering happening: the audio is generated inside the callback.
  *
  * This design is less flexible than running our own thread:
  * - We have no control over the thread:
@@ -350,18 +349,17 @@ class AudioCallbackDriver : public Graph
 #if defined(XP_WIN)
     ,
                             public audio::DeviceChangeListener
 #endif
 {
  public:
   /** If aInputChannelCount is zero, then this driver is output-only. */
   AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl,
-                      uint32_t aInputChannelCount,
-                      AudioInputType aAudioInputType);
+                      uint32_t aInputChannelCount);
   virtual ~AudioCallbackDriver();
 
   void Start() override;
   void Revive() override;
   void WaitForNextIteration() override;
   void WakeUp() override;
   void Shutdown() override;
 #if defined(XP_WIN)
@@ -399,23 +397,16 @@ class AudioCallbackDriver : public Graph
 
   uint32_t OutputChannelCount() {
     MOZ_ASSERT(mOutputChannels != 0 && mOutputChannels <= 8);
     return mOutputChannels;
   }
 
   uint32_t InputChannelCount() { return mInputChannelCount; }
 
-  AudioInputType InputDevicePreference() {
-    if (mInputDevicePreference == CUBEB_DEVICE_PREF_VOICE) {
-      return AudioInputType::Voice;
-    }
-    return AudioInputType::Unknown;
-  }
-
   /* Enqueue a promise that is going to be resolved when a specific operation
    * occurs on the cubeb stream. */
   void EnqueueStreamAndPromiseForOperation(
       MediaStream* aStream, void* aPromise,
       dom::AudioContextOperation aOperation,
       dom::AudioContextOperationFlags aFlags);
 
   std::thread::id ThreadId() { return mAudioThreadId.load(); }
@@ -507,22 +498,22 @@ class AudioCallbackDriver : public Graph
     AudioCallbackDriver* mDriver;
   };
 
   /* Shared thread pool with up to one thread for off-main-thread
    * initialization and shutdown of the audio stream via AsyncCubebTask. */
   const RefPtr<SharedThreadPool> mInitShutdownThread;
   /* This must be accessed with the graph monitor held. */
   AutoTArray<StreamAndPromiseForOperation, 1> mPromisesForOperation;
-  cubeb_device_pref mInputDevicePreference;
   /* This is used to signal adding the mixer callback on first run
    * of audio callback. This is atomic because it is touched from different
    * threads, the audio callback thread and the state change thread. However,
    * the order of the threads does not allow concurent access. */
   Atomic<bool> mAddedMixer;
+
   /* Contains the id of the audio thread for as long as the callback
    * is taking place, after that it is reseted to an invalid value. */
   std::atomic<std::thread::id> mAudioThreadId;
   /* True when audio thread is running. False before
    * starting and after stopping it the audio thread. */
   Atomic<bool> mAudioThreadRunning;
   /* Indication of whether a fallback SystemClockDriver should be started if
    * StateCallback() receives an error.  No mutex need be held during access.
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -363,18 +363,18 @@ void MediaStreamGraphImpl::UpdateStreamO
     MonitorAutoLock mon(mMonitor);
     switching = CurrentDriver()->Switching();
   }
 
   if (audioTrackPresent && mRealtime &&
       !CurrentDriver()->AsAudioCallbackDriver() && !switching) {
     MonitorAutoLock mon(mMonitor);
     if (LifecycleStateRef() == LIFECYCLE_RUNNING) {
-      AudioCallbackDriver* driver = new AudioCallbackDriver(
-          this, AudioInputChannelCount(), AudioInputDevicePreference());
+      AudioCallbackDriver* driver =
+          new AudioCallbackDriver(this, AudioInputChannelCount());
       CurrentDriver()->SwitchAtNextIteration(driver);
     }
   }
 
   if (!mStreamOrderDirty) {
     return;
   }
 
@@ -607,18 +607,18 @@ void MediaStreamGraphImpl::CreateOrDestr
       {
         MonitorAutoLock lock(mMonitor);
         switching = CurrentDriver()->Switching();
       }
 
       if (!CurrentDriver()->AsAudioCallbackDriver() && !switching) {
         MonitorAutoLock mon(mMonitor);
         if (LifecycleStateRef() == LIFECYCLE_RUNNING) {
-          AudioCallbackDriver* driver = new AudioCallbackDriver(
-              this, AudioInputChannelCount(), AudioInputDevicePreference());
+          AudioCallbackDriver* driver =
+              new AudioCallbackDriver(this, AudioInputChannelCount());
           CurrentDriver()->SwitchAtNextIteration(driver);
         }
       }
     }
   }
 
   for (int32_t i = audioOutputStreamsFound.Length() - 1; i >= 0; --i) {
     if (!audioOutputStreamsFound[i]) {
@@ -741,18 +741,18 @@ void MediaStreamGraphImpl::OpenAudioInpu
 
   listeners.AppendElement(aListener);
 
   if (listeners.Length() == 1) {  // first open for this device
     mInputDeviceID = aID;
     // Switch Drivers since we're adding input (to input-only or full-duplex)
     MonitorAutoLock mon(mMonitor);
     if (LifecycleStateRef() == LIFECYCLE_RUNNING) {
-      AudioCallbackDriver* driver = new AudioCallbackDriver(
-          this, AudioInputChannelCount(), AudioInputDevicePreference());
+      AudioCallbackDriver* driver =
+          new AudioCallbackDriver(this, AudioInputChannelCount());
       LOG(LogLevel::Debug,
           ("%p OpenAudioInput: starting new AudioCallbackDriver(input) %p",
            this, driver));
       CurrentDriver()->SwitchAtNextIteration(driver);
     } else {
       LOG(LogLevel::Error, ("OpenAudioInput in shutdown!"));
       MOZ_ASSERT_UNREACHABLE("Can't open cubeb inputs in shutdown");
     }
@@ -825,18 +825,17 @@ void MediaStreamGraphImpl::CloseAudioInp
   MonitorAutoLock mon(mMonitor);
   if (LifecycleStateRef() == LIFECYCLE_RUNNING) {
     GraphDriver* driver;
     if (audioTrackPresent) {
       // We still have audio output
       LOG(LogLevel::Debug,
           ("%p: CloseInput: output present (AudioCallback)", this));
 
-      driver = new AudioCallbackDriver(this, AudioInputChannelCount(),
-                                       AudioInputDevicePreference());
+      driver = new AudioCallbackDriver(this, AudioInputChannelCount());
       CurrentDriver()->SwitchAtNextIteration(driver);
     } else if (CurrentDriver()->AsAudioCallbackDriver()) {
       LOG(LogLevel::Debug,
           ("%p: CloseInput: no output present (SystemClockCallback)", this));
 
       driver = new SystemClockDriver(this);
       CurrentDriver()->SwitchAtNextIteration(driver);
     }  // else SystemClockDriver->SystemClockDriver, no switch
@@ -977,34 +976,30 @@ void MediaStreamGraphImpl::ReevaluateInp
   bool needToSwitch = false;
 
   if (CurrentDriver()->AsAudioCallbackDriver()) {
     AudioCallbackDriver* audioCallbackDriver =
         CurrentDriver()->AsAudioCallbackDriver();
     if (audioCallbackDriver->InputChannelCount() != AudioInputChannelCount()) {
       needToSwitch = true;
     }
-    if (audioCallbackDriver->InputDevicePreference() !=
-        AudioInputDevicePreference()) {
-      needToSwitch = true;
-    }
   } else {
     // We're already in the process of switching to a audio callback driver,
     // which will happen at the next iteration.
     // However, maybe it's not the correct number of channels. Re-query the
     // correct channel amount at this time.
 #ifdef DEBUG
     MonitorAutoLock lock(mMonitor);
     MOZ_ASSERT(CurrentDriver()->Switching());
 #endif
     needToSwitch = true;
   }
   if (needToSwitch) {
-    AudioCallbackDriver* newDriver = new AudioCallbackDriver(
-        this, AudioInputChannelCount(), AudioInputDevicePreference());
+    AudioCallbackDriver* newDriver =
+        new AudioCallbackDriver(this, AudioInputChannelCount());
     {
       MonitorAutoLock lock(mMonitor);
       CurrentDriver()->SwitchAtNextIteration(newDriver);
     }
   }
 }
 
 bool MediaStreamGraphImpl::OnGraphThreadOrNotRunning() const {
@@ -3153,19 +3148,18 @@ MediaStreamGraphImpl::MediaStreamGraphIm
 #ifdef DEBUG
       ,
       mCanRunMessagesSynchronously(false)
 #endif
       ,
       mMainThreadGraphTime(0, "MediaStreamGraphImpl::mMainThreadGraphTime") {
   if (mRealtime) {
     if (aDriverRequested == AUDIO_THREAD_DRIVER) {
-      // Always start with zero input channels, and no particular preferences
-      // for the input channel.
-      mDriver = new AudioCallbackDriver(this, 0, AudioInputType::Unknown);
+      // Always start with zero input channels.
+      mDriver = new AudioCallbackDriver(this, 0);
     } else {
       mDriver = new SystemClockDriver(this);
     }
 
 #ifdef TRACING
     // This is a noop if the logger has not been enabled.
     gMSGTraceLogger.Start();
     gMSGTraceLogger.Log("[");
@@ -3646,18 +3640,17 @@ void MediaStreamGraphImpl::ApplyAudioCon
   // anyways, but doing this now save some time.
   if (aOperation == AudioContextOperation::Resume) {
     if (!CurrentDriver()->AsAudioCallbackDriver()) {
       AudioCallbackDriver* driver;
       if (switching) {
         MOZ_ASSERT(nextDriver->AsAudioCallbackDriver());
         driver = nextDriver->AsAudioCallbackDriver();
       } else {
-        driver = new AudioCallbackDriver(this, AudioInputChannelCount(),
-                                         AudioInputDevicePreference());
+        driver = new AudioCallbackDriver(this, AudioInputChannelCount());
         MonitorAutoLock lock(mMonitor);
         CurrentDriver()->SwitchAtNextIteration(driver);
       }
       driver->EnqueueStreamAndPromiseForOperation(aDestinationStream, aPromise,
                                                   aOperation, aFlags);
     } else {
       // We are resuming a context, but we are already using an
       // AudioCallbackDriver, we can resolve the promise now.
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -118,20 +118,16 @@ class AudioDataListenerInterface {
                                TrackRate aRate, uint32_t aChannels) = 0;
 
   /**
    * Number of audio input channels.
    */
   virtual uint32_t RequestedInputChannelCount(MediaStreamGraphImpl* aGraph) = 0;
 
   /**
-   * Whether the underlying audio device is used for voice input.
-   */
-  virtual bool IsVoiceInput(MediaStreamGraphImpl* aGraph) const = 0;
-  /**
    * Called when the underlying audio device has changed.
    */
   virtual void DeviceChanged(MediaStreamGraphImpl* aGraph) = 0;
 
   /**
    * Called when the underlying audio device is being closed.
    */
   virtual void Disconnect(MediaStreamGraphImpl* aGraph) = 0;
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -393,17 +393,16 @@ class MediaStreamGraphImpl : public Medi
    * anymore, for a particular stream. It can be that other streams still need
    * audio from this audio input device. */
   virtual void CloseAudioInput(Maybe<CubebUtils::AudioDeviceID>& aID,
                                AudioDataListener* aListener) override;
   /* Called on the graph thread when the input device settings should be
    * reevaluated, for example, if the channel count of the input stream should
    * be changed. */
   void ReevaluateInputDevice();
-
   /* Called on the graph thread when there is new output data for listeners.
    * This is the mixed audio output of this MediaStreamGraph. */
   void NotifyOutputData(AudioDataValue* aBuffer, size_t aFrames,
                         TrackRate aRate, uint32_t aChannels);
   /* Called on the graph thread when there is new input data for listeners. This
    * is the raw audio input for this MediaStreamGraph. */
   void NotifyInputData(const AudioDataValue* aBuffer, size_t aFrames,
                        TrackRate aRate, uint32_t aChannels);
@@ -481,39 +480,16 @@ class MediaStreamGraphImpl : public Medi
     MOZ_ASSERT(listeners);
     for (const auto& listener : *listeners) {
       maxInputChannels = std::max(maxInputChannels,
                                   listener->RequestedInputChannelCount(this));
     }
     return maxInputChannels;
   }
 
-  AudioInputType AudioInputDevicePreference() {
-    MOZ_ASSERT(OnGraphThreadOrNotRunning());
-
-    if (!mInputDeviceUsers.GetValue(mInputDeviceID)) {
-      return AudioInputType::Unknown;
-    }
-    bool voiceInput = false;
-    // When/if we decide to support multiple input device per graph, this needs
-    // loop over them.
-    nsTArray<RefPtr<AudioDataListener>>* listeners =
-        mInputDeviceUsers.GetValue(mInputDeviceID);
-    MOZ_ASSERT(listeners);
-
-    // If at least one stream is considered to be voice,
-    for (const auto& listener : *listeners) {
-      voiceInput |= listener->IsVoiceInput(this);
-    }
-    if (voiceInput) {
-      return AudioInputType::Voice;
-    }
-    return AudioInputType::Unknown;
-  }
-
   CubebUtils::AudioDeviceID InputDeviceID() { return mInputDeviceID; }
 
   double MediaTimeToSeconds(GraphTime aTime) const {
     NS_ASSERTION(aTime > -STREAM_TIME_MAX && aTime <= STREAM_TIME_MAX,
                  "Bad time");
     return static_cast<double>(aTime) / GraphRate();
   }
 
--- a/dom/media/webrtc/MediaEngineWebRTC.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTC.cpp
@@ -175,24 +175,19 @@ void MediaEngineWebRTC::EnumerateMicroph
       RefPtr<MediaDevice> device = MakeRefPtr<MediaDevice>(
           source, source->GetName(), NS_ConvertUTF8toUTF16(source->GetUUID()),
           source->GetGroupId(), NS_LITERAL_STRING(""));
       if (devices[i]->Preferred()) {
 #ifdef DEBUG
         if (!foundPreferredDevice) {
           foundPreferredDevice = true;
         } else {
-          // This is possible on windows, there is a default communication
-          // device, and a default device:
-          // See https://bugzilla.mozilla.org/show_bug.cgi?id=1542739
-#ifndef XP_WIN
           MOZ_ASSERT(!foundPreferredDevice,
                      "Found more than one preferred audio input device"
                      "while enumerating");
-#endif
         }
 #endif
         aDevices->InsertElementAt(0, device);
       } else {
         aDevices->AppendElement(device);
       }
     }
   }
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.h
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.h
@@ -155,22 +155,16 @@ class AudioInputProcessing : public Audi
   void Pull(StreamTime aEndOfAppendedData, StreamTime aDesiredTime);
 
   void NotifyOutputData(MediaStreamGraphImpl* aGraph, AudioDataValue* aBuffer,
                         size_t aFrames, TrackRate aRate,
                         uint32_t aChannels) override;
   void NotifyInputData(MediaStreamGraphImpl* aGraph,
                        const AudioDataValue* aBuffer, size_t aFrames,
                        TrackRate aRate, uint32_t aChannels) override;
-  bool IsVoiceInput(MediaStreamGraphImpl* aGraph) const override {
-    // If we're passing data directly without AEC or any other process, this
-    // means that all voice-processing has been disabled intentionaly. In this
-    // case, consider that the device is not used for voice input.
-    return !PassThrough(aGraph);
-  }
 
   void Start();
   void Stop();
 
   void DeviceChanged(MediaStreamGraphImpl* aGraph) override;
 
   uint32_t RequestedInputChannelCount(MediaStreamGraphImpl* aGraph) override {
     return GetRequestedInputChannelCount(aGraph);
--- a/media/libcubeb/disable-device-switching.patch
+++ b/media/libcubeb/disable-device-switching.patch
@@ -1,8 +1,39 @@
+diff --git a/media/libcubeb/include/cubeb.h b/media/libcubeb/include/cubeb.h
+--- a/media/libcubeb/include/cubeb.h
++++ b/media/libcubeb/include/cubeb.h
+@@ -216,20 +216,23 @@ enum {
+                          CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY |
+                          CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT |
+                          CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT,
+ };
+ 
+ /** Miscellaneous stream preferences. */
+ typedef enum {
+   CUBEB_STREAM_PREF_NONE     = 0x00, /**< No stream preferences are requested. */
+-  CUBEB_STREAM_PREF_LOOPBACK = 0x01 /**< Request a loopback stream. Should be
+-                                         specified on the input params and an
+-                                         output device to loopback from should
+-                                         be passed in place of an input device. */
++  CUBEB_STREAM_PREF_LOOPBACK = 0x01, /**< Request a loopback stream. Should be
++                                          specified on the input params and an
++                                          output device to loopback from should
++                                          be passed in place of an input device. */
++  CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
++                                                          default device on OS
++                                                          changes. */
+ } cubeb_stream_prefs;
+ 
+ /** Stream format initialization parameters. */
+ typedef struct {
+   cubeb_sample_format format;   /**< Requested sample format.  One of
+                                      #cubeb_sample_format. */
+   uint32_t rate;                /**< Requested sample rate.  Valid range is [1000, 192000]. */
+   uint32_t channels;            /**< Requested channel count.  Valid range is [1, 8]. */
 diff --git a/media/libcubeb/src/cubeb_wasapi.cpp b/media/libcubeb/src/cubeb_wasapi.cpp
 --- a/media/libcubeb/src/cubeb_wasapi.cpp
 +++ b/media/libcubeb/src/cubeb_wasapi.cpp
 @@ -1829,21 +1829,26 @@ wasapi_stream_init(cubeb * context, cube
         assert that the lock is held in the function. */
      auto_lock lock(stm->stream_reset_lock);
      rv = setup_wasapi_stream(stm.get());
    }
@@ -49,31 +80,8 @@ diff --git a/media/libcubeb/src/cubeb_wa
  
    CloseHandle(stm->reconfigure_event);
    CloseHandle(stm->refill_event);
    CloseHandle(stm->input_available_event);
  
    // The variables intialized in wasapi_stream_init,
    // must be destroyed in wasapi_stream_destroy.
    stm->linear_input_buffer.reset();
-diff --git a/media/libcubeb/include/cubeb.h b/media/libcubeb/include/cubeb.h
---- a/media/libcubeb/include/cubeb.h
-+++ a/media/libcubeb/include/cubeb.h
-@@ -222,16 +222,19 @@
- 
- /** Miscellaneous stream preferences. */
- typedef enum {
-   CUBEB_STREAM_PREF_NONE     = 0x00, /**< No stream preferences are requested. */
-   CUBEB_STREAM_PREF_LOOPBACK = 0x01, /**< Request a loopback stream. Should be
-                                          specified on the input params and an
-                                          output device to loopback from should
-                                          be passed in place of an input device. */
-+  CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
-+                                                          default device on OS
-+                                                          changes. */
-   CUBEB_STREAM_PREF_VOICE = 0x04  /**< This stream is going to transport voice data.
-                                        Depending on the backend and platform, this can
-                                        change the audio input or output devices
-                                        selected, as well as the quality of the stream,
-                                        for example to accomodate bluetooth SCO modes on
-                                        bluetooth devices. */
- } cubeb_stream_prefs;
- 
--- a/media/libcubeb/include/cubeb.h
+++ b/media/libcubeb/include/cubeb.h
@@ -219,28 +219,22 @@ enum {
                          CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT |
                          CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT,
 };
 
 /** Miscellaneous stream preferences. */
 typedef enum {
   CUBEB_STREAM_PREF_NONE     = 0x00, /**< No stream preferences are requested. */
   CUBEB_STREAM_PREF_LOOPBACK = 0x01, /**< Request a loopback stream. Should be
-                                         specified on the input params and an
-                                         output device to loopback from should
-                                         be passed in place of an input device. */
+                                          specified on the input params and an
+                                          output device to loopback from should
+                                          be passed in place of an input device. */
   CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING = 0x02, /**< Disable switching
                                                           default device on OS
                                                           changes. */
-  CUBEB_STREAM_PREF_VOICE = 0x04  /**< This stream is going to transport voice data.
-                                       Depending on the backend and platform, this can
-                                       change the audio input or output devices
-                                       selected, as well as the quality of the stream,
-                                       for example to accomodate bluetooth SCO modes on
-                                       bluetooth devices. */
 } cubeb_stream_prefs;
 
 /** Stream format initialization parameters. */
 typedef struct {
   cubeb_sample_format format;   /**< Requested sample format.  One of
                                      #cubeb_sample_format. */
   uint32_t rate;                /**< Requested sample rate.  Valid range is [1000, 192000]. */
   uint32_t channels;            /**< Requested channel count.  Valid range is [1, 8]. */
--- a/media/libcubeb/moz.yaml
+++ b/media/libcubeb/moz.yaml
@@ -14,10 +14,10 @@ bugzilla:
 origin:
   name: "cubeb"
   description: "Cross platform audio library"
 
   url: "https://github.com/kinetiknz/cubeb"
   license: "ISC"
 
   # update.sh will update this value
-  release: "c0a71704ae935666ecbd0e8a61345de583139607 (2019-04-10 18:19:29 +0200)"
+  release: "66d9c48d916f00c396482f9c5075feacc2bc0db8 (2019-04-03 12:41:20 +0300)"
 
--- a/media/libcubeb/src/android/sles_definitions.h
+++ b/media/libcubeb/src/android/sles_definitions.h
@@ -38,19 +38,20 @@
 #define SL_ANDROID_RECORDING_PRESET_GENERIC             ((SLuint32) 0x00000001)
 /**   uses the microphone audio source with the same orientation as the camera
  *     if available, the main device microphone otherwise */
 #define SL_ANDROID_RECORDING_PRESET_CAMCORDER           ((SLuint32) 0x00000002)
 /**   uses the main microphone tuned for voice recognition */
 #define SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION   ((SLuint32) 0x00000003)
 /**   uses the main microphone tuned for audio communications */
 #define SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION ((SLuint32) 0x00000004)
-/**   uses the main microphone unprocessed */
-#define SL_ANDROID_RECORDING_PRESET_UNPROCESSED         ((SLuint32) 0x00000005)
 
+/** Audio recording get session ID (read only) */
+/** Audio recording get session ID key */
+#define SL_ANDROID_KEY_RECORDING_SESSION_ID ((const SLchar*) "androidRecordingSessionId")
 
 /*---------------------------------------------------------------------------*/
 /* Android AudioPlayer configuration                                         */
 /*---------------------------------------------------------------------------*/
 
 /** Audio playback stream type */
 /** Audio playback stream type key */
 #define SL_ANDROID_KEY_STREAM_TYPE ((const SLchar*) "androidPlaybackStreamType")
@@ -63,40 +64,14 @@
 /*      same as android.media.AudioManager.STREAM_RING */
 #define SL_ANDROID_STREAM_RING         ((SLint32) 0x00000002)
 /*      same as android.media.AudioManager.STREAM_MUSIC */
 #define SL_ANDROID_STREAM_MEDIA        ((SLint32) 0x00000003)
 /*      same as android.media.AudioManager.STREAM_ALARM */
 #define SL_ANDROID_STREAM_ALARM        ((SLint32) 0x00000004)
 /*      same as android.media.AudioManager.STREAM_NOTIFICATION */
 #define SL_ANDROID_STREAM_NOTIFICATION ((SLint32) 0x00000005)
-
-
-/*---------------------------------------------------------------------------*/
-/* Android AudioPlayer and AudioRecorder configuration                       */
-/*---------------------------------------------------------------------------*/
-
-/** Audio Performance mode.
- * Performance mode tells the framework how to configure the audio path
- * for a player or recorder according to application performance and
- * functional requirements.
- * It affects the output or input latency based on acceptable tradeoffs on
- * battery drain and use of pre or post processing effects.
- * Performance mode should be set before realizing the object and should be
- * read after realizing the object to check if the requested mode could be
- * granted or not.
- */
-/** Audio Performance mode key */
-#define SL_ANDROID_KEY_PERFORMANCE_MODE ((const SLchar*) "androidPerformanceMode")
-
-/** Audio performance values */
-/*      No specific performance requirement. Allows HW and SW pre/post processing. */
-#define SL_ANDROID_PERFORMANCE_NONE ((SLuint32) 0x00000000)
-/*      Priority given to latency. No HW or software pre/post processing.
- *      This is the default if no performance mode is specified. */
-#define SL_ANDROID_PERFORMANCE_LATENCY ((SLuint32) 0x00000001)
-/*      Priority given to latency while still allowing HW pre and post processing. */
-#define SL_ANDROID_PERFORMANCE_LATENCY_EFFECTS ((SLuint32) 0x00000002)
-/*      Priority given to power saving if latency is not a concern.
- *      Allows HW and SW pre/post processing. */
-#define SL_ANDROID_PERFORMANCE_POWER_SAVING ((SLuint32) 0x00000003)
+/*      same as android.media.AudioManager.STREAM_BLUETOOTH_SCO */
+#define SL_ANDROID_STREAM_BLUETOOTH_SCO ((SLint32) 0x00000006)
+/*      same as android.media.AudioManager.STREAM_SYSTEM_ENFORCED */
+#define SL_ANDROID_STREAM_SYSTEM_ENFORCED ((SLint32) 0x00000007)
 
 #endif /* OPENSL_ES_ANDROIDCONFIGURATION_H_ */
--- a/media/libcubeb/src/cubeb_audiounit.cpp
+++ b/media/libcubeb/src/cubeb_audiounit.cpp
@@ -863,17 +863,17 @@ audiounit_reinit_stream(cubeb_stream * s
   return CUBEB_OK;
 }
 
 static void
 audiounit_reinit_stream_async(cubeb_stream * stm, device_flags_value flags)
 {
   if (std::atomic_exchange(&stm->reinit_pending, true)) {
     // A reinit task is already pending, nothing more to do.
-    ALOG("(%p) re-init stream task already pending, cancelling request", stm);
+    ALOG("(%p) re-init stream task already pending, cancelling request ", stm);
     return;
   }
 
   // Use a new thread, through the queue, to avoid deadlock when calling
   // Get/SetProperties method from inside notify callback
   dispatch_async(stm->context->serial_queue, ^() {
     if (stm->destroy_pending) {
       ALOG("(%p) stream pending destroy, cancelling reinit task", stm);
@@ -939,17 +939,17 @@ audiounit_property_listener_callback(Aud
           if (stm->input_device.flags & DEV_SYSTEM_DEFAULT) {
             LOG("It's the default input device, ignore the event");
             stm->switching_device = false;
             return noErr;
           }
         }
         break;
       case kAudioDevicePropertyDataSource: {
-          LOG("Event[%u] - mSelector == kAudioDevicePropertyDataSource for id=%d", (unsigned int) i, id);
+          LOG("Event[%u] - mSelector == kAudioHardwarePropertyDataSource for id=%d", (unsigned int) i, id);
         }
         break;
       default:
         LOG("Event[%u] - mSelector == Unexpected Event id %d, return", (unsigned int) i, addresses[i].mSelector);
         stm->switching_device = false;
         return noErr;
     }
   }
@@ -1309,19 +1309,19 @@ audiounit_get_preferred_sample_rate(cube
   *rate = static_cast<uint32_t>(fsamplerate);
 #endif
   return CUBEB_OK;
 }
 
 static cubeb_channel_layout
 audiounit_convert_channel_layout(AudioChannelLayout * layout)
 {
-  // When having one or two channel, force mono or stereo. Some devices (namely,
-  // Bose QC35, mark 1 and 2), expose a single channel mapped to the right for
-  // some reason.
+  // When having on or two channel, force mono or stereo. Some devices (namely,
+  //  Bose QC35, mark 1 and 2), expose a single channel mapped to the right for
+  //  some reason.
   if (layout->mNumberChannelDescriptions == 1) {
     return CUBEB_LAYOUT_MONO;
   } else if (layout->mNumberChannelDescriptions == 2) {
     return CUBEB_LAYOUT_STEREO;
   }
 
   if (layout->mChannelLayoutTag != kAudioChannelLayoutTag_UseChannelDescriptions) {
     // kAudioChannelLayoutTag_UseChannelBitmap
@@ -1606,17 +1606,17 @@ audiounit_create_blank_aggregate_device(
                                                           kAudioObjectPropertyScopeGlobal,
                                                           kAudioObjectPropertyElementMaster };
   UInt32 size = 0;
   OSStatus r = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
                                               &address_plugin_bundle_id,
                                               0, NULL,
                                               &size);
   if (r != noErr) {
-    LOG("AudioObjectGetPropertyDataSize/kAudioHardwarePropertyPlugInForBundleID, rv=%d", r);
+    LOG("AudioHardwareGetPropertyInfo/kAudioHardwarePropertyPlugInForBundleID, rv=%d", r);
     return CUBEB_ERROR;
   }
 
   AudioValueTranslation translation_value;
   CFStringRef in_bundle_ref = CFSTR("com.apple.audio.CoreAudio");
   translation_value.mInputData = &in_bundle_ref;
   translation_value.mInputDataSize = sizeof(in_bundle_ref);
   translation_value.mOutputData = plugin_id;
@@ -1624,17 +1624,17 @@ audiounit_create_blank_aggregate_device(
 
   r = AudioObjectGetPropertyData(kAudioObjectSystemObject,
                                  &address_plugin_bundle_id,
                                  0,
                                  nullptr,
                                  &size,
                                  &translation_value);
   if (r != noErr) {
-    LOG("AudioObjectGetPropertyData/kAudioHardwarePropertyPlugInForBundleID, rv=%d", r);
+    LOG("AudioHardwareGetProperty/kAudioHardwarePropertyPlugInForBundleID, rv=%d", r);
     return CUBEB_ERROR;
   }
 
   AudioObjectPropertyAddress create_aggregate_device_address = { kAudioPlugInCreateAggregateDevice,
                                                                  kAudioObjectPropertyScopeGlobal,
                                                                  kAudioObjectPropertyElementMaster };
   r = AudioObjectGetPropertyDataSize(*plugin_id,
                                      &create_aggregate_device_address,
@@ -2067,33 +2067,33 @@ audiounit_create_unit(AudioUnit * unit, 
       (device->flags & DEV_OUTPUT)) {
     return CUBEB_OK;
   }
 
 
   if (device->flags & DEV_INPUT) {
     r = audiounit_enable_unit_scope(unit, io_side::INPUT, ENABLE);
     if (r != CUBEB_OK) {
-      LOG("Failed to enable audiounit input scope");
+      LOG("Failed to enable audiounit input scope ");
       return r;
     }
     r = audiounit_enable_unit_scope(unit, io_side::OUTPUT, DISABLE);
     if (r != CUBEB_OK) {
-      LOG("Failed to disable audiounit output scope");
+      LOG("Failed to disable audiounit output scope ");
       return r;
     }
   } else if (device->flags & DEV_OUTPUT) {
     r = audiounit_enable_unit_scope(unit, io_side::OUTPUT, ENABLE);
     if (r != CUBEB_OK) {
-      LOG("Failed to enable audiounit output scope");
+      LOG("Failed to enable audiounit output scope ");
       return r;
     }
     r = audiounit_enable_unit_scope(unit, io_side::INPUT, DISABLE);
     if (r != CUBEB_OK) {
-      LOG("Failed to disable audiounit input scope");
+      LOG("Failed to disable audiounit input scope ");
       return r;
     }
   } else {
     assert(false);
   }
 
   rv = AudioUnitSetProperty(*unit,
                             kAudioOutputUnitProperty_CurrentDevice,
@@ -2583,26 +2583,26 @@ audiounit_setup_stream(cubeb_stream * st
     r = audiounit_create_unit(&stm->output_unit, &out_dev_info);
     if (r != CUBEB_OK) {
       LOG("(%p) AudioUnit creation for output failed.", stm);
       return r;
     }
   }
 
   /* Latency cannot change if another stream is operating in parallel. In this case
-   * latency is set to the other stream value. */
+  * latecy is set to the other stream value. */
   if (audiounit_active_streams(stm->context) > 1) {
     LOG("(%p) More than one active stream, use global latency.", stm);
     stm->latency_frames = stm->context->global_latency_frames;
   } else {
     /* Silently clamp the latency down to the platform default, because we
-     * synthetize the clock from the callbacks, and we want the clock to update
-     * often. */
+    * synthetize the clock from the callbacks, and we want the clock to update
+    * often. */
     stm->latency_frames = audiounit_clamp_latency(stm, stm->latency_frames);
-    assert(stm->latency_frames); // Ugly error check
+    assert(stm->latency_frames); // Ungly error check
     audiounit_set_global_latency(stm->context, stm->latency_frames);
   }
 
   /* Configure I/O stream */
   if (has_input(stm)) {
     r = audiounit_configure_input(stm);
     if (r != CUBEB_OK) {
       LOG("(%p) Configure audiounit input failed.", stm);
--- a/media/libcubeb/src/cubeb_opensl.c
+++ b/media/libcubeb/src/cubeb_opensl.c
@@ -58,21 +58,16 @@
 
 #define ANDROID_VERSION_GINGERBREAD_MR1 10
 #define ANDROID_VERSION_LOLLIPOP 21
 #define ANDROID_VERSION_MARSHMALLOW 23
 #endif
 
 #define DEFAULT_SAMPLE_RATE 48000
 #define DEFAULT_NUM_OF_FRAMES 480
-// If the latency requested is above this threshold, this stream is considered
-// intended for playback (vs. real-time). Tell Android it should favor saving
-// power over performance or latency.
-// This is around 100ms at 44100 or 48000
-#define POWERSAVE_LATENCY_FRAMES_THRESHOLD 4000
 
 static struct cubeb_ops const opensl_ops;
 
 struct cubeb {
   struct cubeb_ops const * ops;
   void * lib;
   SLInterfaceID SL_IID_BUFFERQUEUE;
   SLInterfaceID SL_IID_PLAY;
@@ -84,17 +79,17 @@ struct cubeb {
   SLInterfaceID SL_IID_RECORD;
   SLObjectItf engObj;
   SLEngineItf eng;
   SLObjectItf outmixObj;
   output_latency_function * p_output_latency_function;
 };
 
 #define NELEMS(A) (sizeof(A) / sizeof A[0])
-#define NBUFS 2
+#define NBUFS 4
 
 struct cubeb_stream {
   /* Note: Must match cubeb_stream layout in cubeb.c. */
   cubeb * context;
   void * user_ptr;
   /**/
   pthread_mutex_t mutex;
   SLObjectItf playerObj;
@@ -155,23 +150,20 @@ struct cubeb_stream {
   /* Store user callback. */
   cubeb_data_callback data_callback;
   /* Store state callback. */
   cubeb_state_callback state_callback;
 
   cubeb_resampler * resampler;
   unsigned int user_output_rate;
   unsigned int output_configured_rate;
-  unsigned int buffer_size_frames;
-  // Audio output latency used in cubeb_stream_get_position().
-  unsigned int output_latency_ms;
+  unsigned int latency_frames;
   int64_t lastPosition;
   int64_t lastPositionTimeStamp;
   int64_t lastCompensativePosition;
-  int voice;
 };
 
 /* Forward declaration. */
 static int opensl_stop_player(cubeb_stream * stm);
 static int opensl_stop_recorder(cubeb_stream * stm);
 
 static int
 opensl_get_draining(cubeb_stream * stm)
@@ -849,27 +841,26 @@ opensl_configure_capture(cubeb_stream * 
   lDataLocatorIn.deviceType = SL_IODEVICE_AUDIOINPUT;
   lDataLocatorIn.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT;
   lDataLocatorIn.device = NULL;
 
   SLDataSource lDataSource;
   lDataSource.pLocator = &lDataLocatorIn;
   lDataSource.pFormat = NULL;
 
+  const SLuint32 lSoundRecorderIIDCount = 2;
   const SLInterfaceID lSoundRecorderIIDs[] = { stm->context->SL_IID_RECORD,
-                                               stm->context->SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
-                                               stm->context->SL_IID_ANDROIDCONFIGURATION };
-
-  const SLboolean lSoundRecorderReqs[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
+                                               stm->context->SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
+  const SLboolean lSoundRecorderReqs[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
   // create the audio recorder abstract object
   SLresult res = (*stm->context->eng)->CreateAudioRecorder(stm->context->eng,
                                                            &stm->recorderObj,
                                                            &lDataSource,
                                                            &lDataSink,
-                                                           NELEMS(lSoundRecorderIIDs),
+                                                           lSoundRecorderIIDCount,
                                                            lSoundRecorderIIDs,
                                                            lSoundRecorderReqs);
   // Sample rate not supported. Try again with default sample rate!
   if (res == SL_RESULT_CONTENT_UNSUPPORTED) {
     if (stm->output_enabled && stm->output_configured_rate != 0) {
       // Set the same with the player. Since there is no
       // api for input device this is a safe choice.
       stm->input_device_rate = stm->output_configured_rate;
@@ -878,55 +869,26 @@ opensl_configure_capture(cubeb_stream * 
       // The default rate expected to be supported from all android devices.
       stm->input_device_rate = DEFAULT_SAMPLE_RATE;
     }
     lDataFormat.samplesPerSec = stm->input_device_rate * 1000;
     res = (*stm->context->eng)->CreateAudioRecorder(stm->context->eng,
                                                     &stm->recorderObj,
                                                     &lDataSource,
                                                     &lDataSink,
-                                                    NELEMS(lSoundRecorderIIDs),
+                                                    lSoundRecorderIIDCount,
                                                     lSoundRecorderIIDs,
                                                     lSoundRecorderReqs);
 
     if (res != SL_RESULT_SUCCESS) {
       LOG("Failed to create recorder. Error code: %lu", res);
       return CUBEB_ERROR;
     }
   }
 
-  SLAndroidConfigurationItf recorderConfig;
-  res = (*stm->recorderObj)
-            ->GetInterface(stm->recorderObj,
-                           stm->context->SL_IID_ANDROIDCONFIGURATION,
-                           &recorderConfig);
-
-  if (res != SL_RESULT_SUCCESS) {
-    LOG("Failed to get the android configuration interface for recorder. Error "
-        "code: %lu",
-        res);
-    return CUBEB_ERROR;
-  }
-
-  // Voice recognition is the lowest latency, according to the docs. Camcorder
-  // uses a microphone that is in the same direction as the camera.
-  SLint32 streamType = stm->voice ? SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION
-                                  : SL_ANDROID_RECORDING_PRESET_CAMCORDER;
-
-  res = (*recorderConfig)
-            ->SetConfiguration(recorderConfig, SL_ANDROID_KEY_RECORDING_PRESET,
-                               &streamType, sizeof(SLint32));
-
-  if (res != SL_RESULT_SUCCESS) {
-    LOG("Failed to set the android configuration to VOICE for the recorder. "
-        "Error code: %lu",
-        res);
-    return CUBEB_ERROR;
-  }
-
   // realize the audio recorder
   res = (*stm->recorderObj)->Realize(stm->recorderObj, SL_BOOLEAN_FALSE);
   if (res != SL_RESULT_SUCCESS) {
     LOG("Failed to realize recorder. Error code: %lu", res);
     return CUBEB_ERROR;
   }
   // get the record interface
   res = (*stm->recorderObj)->GetInterface(stm->recorderObj,
@@ -970,17 +932,17 @@ opensl_configure_capture(cubeb_stream * 
                                                          stm);
   if (res != SL_RESULT_SUCCESS) {
     LOG("Failed to register recorder buffer queue callback. Error code: %lu", res);
     return CUBEB_ERROR;
   }
 
   // Calculate length of input buffer according to requested latency
   stm->input_frame_size = params->channels * sizeof(int16_t);
-  stm->input_buffer_length = (stm->input_frame_size * stm->buffer_size_frames);
+  stm->input_buffer_length = (stm->input_frame_size * stm->latency_frames);
 
   // Calculate the capacity of input array
   stm->input_array_capacity = NBUFS;
   if (stm->output_enabled) {
     // Full duplex, update capacity to hold 1 sec of data
     stm->input_array_capacity = 1 * stm->input_device_rate / stm->input_buffer_length;
   }
   // Allocate input array
@@ -1081,105 +1043,37 @@ opensl_configure_playback(cubeb_stream *
 
   if (res != SL_RESULT_SUCCESS) {
     LOG("Failed to create audio player. Error code: %lu", res);
     return CUBEB_ERROR;
   }
 
   stm->output_configured_rate = preferred_sampling_rate;
   stm->bytespersec = stm->output_configured_rate * stm->framesize;
-  stm->queuebuf_len = stm->framesize * stm->buffer_size_frames;
+  stm->queuebuf_len = stm->framesize * stm->latency_frames;
 
   // Calculate the capacity of input array
   stm->queuebuf_capacity = NBUFS;
   if (stm->output_enabled) {
     // Full duplex, update capacity to hold 1 sec of data
     stm->queuebuf_capacity = 1 * stm->output_configured_rate / stm->queuebuf_len;
   }
   // Allocate input array
   stm->queuebuf = (void**)calloc(1, sizeof(void*) * stm->queuebuf_capacity);
   for (uint32_t i = 0; i < stm->queuebuf_capacity; ++i) {
     stm->queuebuf[i] = calloc(1, stm->queuebuf_len);
     assert(stm->queuebuf[i]);
   }
 
-  SLAndroidConfigurationItf playerConfig;
-  res = (*stm->playerObj)
-            ->GetInterface(stm->playerObj,
-                           stm->context->SL_IID_ANDROIDCONFIGURATION,
-                           &playerConfig);
-  if (res != SL_RESULT_SUCCESS) {
-    LOG("Failed to get Android configuration interface. Error code: %lu", res);
-    return CUBEB_ERROR;
-  }
-
-  SLint32 streamType = SL_ANDROID_STREAM_MEDIA;
-  if (stm->voice) {
-    streamType = SL_ANDROID_STREAM_VOICE;
-  }
-  res = (*playerConfig)->SetConfiguration(playerConfig,
-                                          SL_ANDROID_KEY_STREAM_TYPE,
-                                          &streamType,
-                                          sizeof(streamType));
-  if (res != SL_RESULT_SUCCESS) {
-    LOG("Failed to set Android configuration to %d Error code: %lu",
-        streamType, res);
-    return CUBEB_ERROR;
-  }
-
-  SLuint32 performanceMode = SL_ANDROID_PERFORMANCE_LATENCY;
-  if (stm->buffer_size_frames > POWERSAVE_LATENCY_FRAMES_THRESHOLD) {
-    performanceMode = SL_ANDROID_PERFORMANCE_POWER_SAVING;
-  }
-
-  res = (*playerConfig)->SetConfiguration(playerConfig,
-                                          SL_ANDROID_KEY_PERFORMANCE_MODE,
-                                          &performanceMode,
-                                          sizeof(performanceMode));
-  if (res != SL_RESULT_SUCCESS) {
-    LOG("Failed to set Android performance mode to %d Error code: %lu. This is"
-        " not fatal", performanceMode, res);
-  }
-
   res = (*stm->playerObj)->Realize(stm->playerObj, SL_BOOLEAN_FALSE);
   if (res != SL_RESULT_SUCCESS) {
     LOG("Failed to realize player object. Error code: %lu", res);
     return CUBEB_ERROR;
   }
 
-  // There are two ways of getting the audio output latency:
-  // - a configuration value, only available on some devices (notably devices
-  // running FireOS)
-  // - A Java method, that we call using JNI.
-  //
-  // The first method is prefered, if available, because it can account for more
-  // latency causes, and is more precise.
-
-  // Latency has to be queried after the realization of the interface, when
-  // using SL_IID_ANDROIDCONFIGURATION.
-  SLuint32 audioLatency = 0;
-  SLuint32 paramSize = sizeof(SLuint32);
-  // The reported latency is in milliseconds.
-  res = (*playerConfig)->GetConfiguration(playerConfig,
-                                          (const SLchar *)"androidGetAudioLatency",
-                                          &paramSize,
-                                          &audioLatency);
-  if (res == SL_RESULT_SUCCESS) {
-    LOG("Got playback latency using android configuration extension");
-    stm->output_latency_ms = audioLatency;
-  } else if (cubeb_output_latency_method_is_loaded(stm->context->p_output_latency_function)) {
-    LOG("Got playback latency using JNI");
-    stm->output_latency_ms = cubeb_get_output_latency(stm->context->p_output_latency_function);
-  } else {
-    LOG("No alternate latency querying method loaded, A/V sync will be off.");
-    stm->output_latency_ms = 0;
-  }
-
-  LOG("Audio output latency: %dms", stm->output_latency_ms);
-
   res = (*stm->playerObj)->GetInterface(stm->playerObj,
                                         stm->context->SL_IID_PLAY,
                                         &stm->play);
   if (res != SL_RESULT_SUCCESS) {
     LOG("Failed to get play interface. Error code: %lu", res);
     return CUBEB_ERROR;
   }
 
@@ -1249,24 +1143,16 @@ opensl_validate_stream_param(cubeb_strea
   if ((stream_params &&
        (stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK))) {
     LOG("Loopback is not supported");
     return CUBEB_ERROR_NOT_SUPPORTED;
   }
   return CUBEB_OK;
 }
 
-int has_pref_set(cubeb_stream_params* input_params,
-                 cubeb_stream_params* output_params,
-                 cubeb_stream_prefs pref)
-{
-  return (input_params && input_params->prefs & pref) ||
-         (output_params && output_params->prefs & pref);
-}
-
 static int
 opensl_stream_init(cubeb * ctx, cubeb_stream ** stream, char const * stream_name,
                    cubeb_devid input_device,
                    cubeb_stream_params * input_stream_params,
                    cubeb_devid output_device,
                    cubeb_stream_params * output_stream_params,
                    unsigned int latency_frames,
                    cubeb_data_callback data_callback, cubeb_state_callback state_callback,
@@ -1294,50 +1180,46 @@ opensl_stream_init(cubeb * ctx, cubeb_st
 
   stm = calloc(1, sizeof(*stm));
   assert(stm);
 
   stm->context = ctx;
   stm->data_callback = data_callback;
   stm->state_callback = state_callback;
   stm->user_ptr = user_ptr;
-  stm->buffer_size_frames = latency_frames ? latency_frames : DEFAULT_NUM_OF_FRAMES;
+  stm->latency_frames = latency_frames ? latency_frames : DEFAULT_NUM_OF_FRAMES;
   stm->input_enabled = (input_stream_params) ? 1 : 0;
   stm->output_enabled = (output_stream_params) ? 1 : 0;
   stm->shutdown = 1;
-  stm->voice = has_pref_set(input_stream_params, output_stream_params, CUBEB_STREAM_PREF_VOICE);
-
-  LOG("cubeb stream prefs: voice: %s", stm->voice ? "true" : "false");
-
 
 #ifdef DEBUG
   pthread_mutexattr_t attr;
   pthread_mutexattr_init(&attr);
   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
   r = pthread_mutex_init(&stm->mutex, &attr);
 #else
   r = pthread_mutex_init(&stm->mutex, NULL);
 #endif
   assert(r == 0);
 
   if (output_stream_params) {
     LOG("Playback params: Rate %d, channels %d, format %d, latency in frames %d.",
         output_stream_params->rate, output_stream_params->channels,
-        output_stream_params->format, stm->buffer_size_frames);
+        output_stream_params->format, stm->latency_frames);
     r = opensl_configure_playback(stm, output_stream_params);
     if (r != CUBEB_OK) {
       opensl_stream_destroy(stm);
       return r;
     }
   }
 
   if (input_stream_params) {
     LOG("Capture params: Rate %d, channels %d, format %d, latency in frames %d.",
         input_stream_params->rate, input_stream_params->channels,
-        input_stream_params->format, stm->buffer_size_frames);
+        input_stream_params->format, stm->latency_frames);
     r = opensl_configure_capture(stm, input_stream_params);
     if (r != CUBEB_OK) {
       opensl_stream_destroy(stm);
       return r;
     }
   }
 
   /* Configure resampler*/
@@ -1565,47 +1447,51 @@ opensl_stream_destroy(cubeb_stream * stm
 
 static int
 opensl_stream_get_position(cubeb_stream * stm, uint64_t * position)
 {
   SLmillisecond msec;
   uint32_t compensation_msec = 0;
   SLresult res;
 
+  if (!cubeb_output_latency_method_is_loaded(stm->context->p_output_latency_function)) {
+    return CUBEB_ERROR_NOT_SUPPORTED;
+  }
+
   res = (*stm->play)->GetPosition(stm->play, &msec);
   if (res != SL_RESULT_SUCCESS)
     return CUBEB_ERROR;
 
   struct timespec t;
   clock_gettime(CLOCK_MONOTONIC, &t);
   if(stm->lastPosition == msec) {
     compensation_msec =
       (t.tv_sec*1000000000LL + t.tv_nsec - stm->lastPositionTimeStamp) / 1000000;
   } else {
     stm->lastPositionTimeStamp = t.tv_sec*1000000000LL + t.tv_nsec;
     stm->lastPosition = msec;
   }
 
   uint64_t samplerate = stm->user_output_rate;
-  uint32_t output_latency = stm->output_latency_ms;
+  uint32_t mixer_latency = cubeb_get_output_latency(stm->context->p_output_latency_function);
 
   pthread_mutex_lock(&stm->mutex);
   int64_t maximum_position = stm->written * (int64_t)stm->user_output_rate / stm->output_configured_rate;
   pthread_mutex_unlock(&stm->mutex);
   assert(maximum_position >= 0);
 
-  if (msec > output_latency) {
+  if (msec > mixer_latency) {
     int64_t unadjusted_position;
     if (stm->lastCompensativePosition > msec + compensation_msec) {
       // Over compensation, use lastCompensativePosition.
       unadjusted_position =
-        samplerate * (stm->lastCompensativePosition - output_latency) / 1000;
+        samplerate * (stm->lastCompensativePosition - mixer_latency) / 1000;
     } else {
       unadjusted_position =
-        samplerate * (msec - output_latency + compensation_msec) / 1000;
+        samplerate * (msec - mixer_latency + compensation_msec) / 1000;
       stm->lastCompensativePosition = msec + compensation_msec;
     }
     *position = unadjusted_position < maximum_position ?
       unadjusted_position : maximum_position;
   } else {
     *position = 0;
   }
   return CUBEB_OK;
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -136,17 +136,16 @@ private:
 };
 
 extern cubeb_ops const wasapi_ops;
 
 int wasapi_stream_stop(cubeb_stream * stm);
 int wasapi_stream_start(cubeb_stream * stm);
 void close_wasapi_stream(cubeb_stream * stm);
 int setup_wasapi_stream(cubeb_stream * stm);
-ERole pref_to_role(cubeb_stream_prefs param);
 static char const * wstr_to_utf8(wchar_t const * str);
 static std::unique_ptr<wchar_t const []> utf8_to_wstr(char const * str);
 
 }
 
 class wasapi_collection_notification_client;
 class monitor_device_notifications;
 
@@ -187,18 +186,16 @@ struct cubeb_stream {
      samplerate/channel layout, as WASAPI does not resample nor upmix
      itself. */
   cubeb_stream_params input_mix_params = { CUBEB_SAMPLE_FLOAT32NE, 0, 0, CUBEB_LAYOUT_UNDEFINED, CUBEB_STREAM_PREF_NONE };
   cubeb_stream_params output_mix_params = { CUBEB_SAMPLE_FLOAT32NE, 0, 0, CUBEB_LAYOUT_UNDEFINED, CUBEB_STREAM_PREF_NONE };
   /* Stream parameters. This is what the client requested,
    * and what will be presented in the callback. */
   cubeb_stream_params input_stream_params = { CUBEB_SAMPLE_FLOAT32NE, 0, 0, CUBEB_LAYOUT_UNDEFINED, CUBEB_STREAM_PREF_NONE };
   cubeb_stream_params output_stream_params = { CUBEB_SAMPLE_FLOAT32NE, 0, 0, CUBEB_LAYOUT_UNDEFINED, CUBEB_STREAM_PREF_NONE };
-  /* A MMDevice role for this stream: either communication or console here. */
-  ERole role;
   /* The input and output device, or NULL for default. */
   std::unique_ptr<const wchar_t[]> input_device;
   std::unique_ptr<const wchar_t[]> output_device;
   /* The latency initially requested for this stream, in frames. */
   unsigned latency = 0;
   cubeb_state_callback state_callback = nullptr;
   cubeb_data_callback data_callback = nullptr;
   wasapi_refill_callback refill_callback = nullptr;
@@ -563,32 +560,31 @@ public:
       *ppvInterface = (IMMNotificationClient*)this;
     } else {
       *ppvInterface = NULL;
       return E_NOINTERFACE;
     }
     return S_OK;
   }
 
-  wasapi_endpoint_notification_client(HANDLE event, ERole role)
+  wasapi_endpoint_notification_client(HANDLE event)
     : ref_count(1)
     , reconfigure_event(event)
-    , role(role)
   { }
 
   virtual ~wasapi_endpoint_notification_client()
   { }
 
   HRESULT STDMETHODCALLTYPE
   OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR device_id)
   {
     LOG("endpoint: Audio device default changed.");
 
     /* we only support a single stream type for now. */
-    if (flow != eRender && role != this->role) {
+    if (flow != eRender && role != eConsole) {
       return S_OK;
     }
 
     BOOL ok = SetEvent(reconfigure_event);
     if (!ok) {
       LOG("endpoint: SetEvent on reconfigure_event failed: %lx", GetLastError());
     }
 
@@ -621,17 +617,16 @@ public:
   {
     //Audio device property value changed.
     return S_OK;
   }
 private:
   /* refcount for this instance, necessary to implement MSCOM semantics. */
   LONG ref_count;
   HANDLE reconfigure_event;
-  ERole role;
 };
 
 namespace {
 
 char const *
 intern_device_id(cubeb * ctx, wchar_t const * id)
 {
   XASSERT(id);
@@ -1256,17 +1251,17 @@ HRESULT register_notification_client(cub
   HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
                                 NULL, CLSCTX_INPROC_SERVER,
                                 IID_PPV_ARGS(stm->device_enumerator.receive()));
   if (FAILED(hr)) {
     LOG("Could not get device enumerator: %lx", hr);
     return hr;
   }
 
-  stm->notification_client.reset(new wasapi_endpoint_notification_client(stm->reconfigure_event, stm->role));
+  stm->notification_client.reset(new wasapi_endpoint_notification_client(stm->reconfigure_event));
 
   hr = stm->device_enumerator->RegisterEndpointNotificationCallback(stm->notification_client.get());
   if (FAILED(hr)) {
     LOG("Could not register endpoint notification callback: %lx", hr);
     stm->notification_client = nullptr;
     stm->device_enumerator = nullptr;
   }
 
@@ -1351,27 +1346,27 @@ HRESULT unregister_collection_notificati
 
   context->collection_notification_client = nullptr;
   context->device_collection_enumerator = nullptr;
 
   context->monitor_notifications.reset();
   return hr;
 }
 
-HRESULT get_default_endpoint(com_ptr<IMMDevice> & device, EDataFlow direction, ERole role)
+HRESULT get_default_endpoint(com_ptr<IMMDevice> & device, EDataFlow direction)
 {
   com_ptr<IMMDeviceEnumerator> enumerator;
   HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
                                 NULL, CLSCTX_INPROC_SERVER,
                                 IID_PPV_ARGS(enumerator.receive()));
   if (FAILED(hr)) {
     LOG("Could not get device enumerator: %lx", hr);
     return hr;
   }
-  hr = enumerator->GetDefaultAudioEndpoint(direction, role, device.receive());
+  hr = enumerator->GetDefaultAudioEndpoint(direction, eConsole, device.receive());
   if (FAILED(hr)) {
     LOG("Could not get default audio endpoint: %lx", hr);
     return hr;
   }
 
   return ERROR_SUCCESS;
 }
 
@@ -1447,21 +1442,21 @@ stream_set_volume(cubeb_stream * stm, fl
 
 extern "C" {
 int wasapi_init(cubeb ** context, char const * context_name)
 {
   /* We don't use the device yet, but need to make sure we can initialize one
      so that this backend is not incorrectly enabled on platforms that don't
      support WASAPI. */
   com_ptr<IMMDevice> device;
-  HRESULT hr = get_default_endpoint(device, eRender, eConsole);
+  HRESULT hr = get_default_endpoint(device, eRender);
   if (FAILED(hr)) {
     XASSERT(hr != CO_E_NOTINITIALIZED);
     LOG("It wasn't able to find a default rendering device: %lx", hr);
-    hr = get_default_endpoint(device, eCapture, eConsole);
+    hr = get_default_endpoint(device, eCapture);
     if (FAILED(hr)) {
       LOG("It wasn't able to find a default capture device: %lx", hr);
       return CUBEB_ERROR;
     }
   }
 
   cubeb * ctx = new cubeb();
 
@@ -1550,17 +1545,17 @@ char const * wasapi_get_backend_id(cubeb
 }
 
 int
 wasapi_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
 {
   XASSERT(ctx && max_channels);
 
   com_ptr<IMMDevice> device;
-  HRESULT hr = get_default_endpoint(device, eRender, eConsole);
+  HRESULT hr = get_default_endpoint(device, eRender);
   if (FAILED(hr)) {
     return CUBEB_ERROR;
   }
 
   com_ptr<IAudioClient> client;
   hr = device->Activate(__uuidof(IAudioClient),
                         CLSCTX_INPROC_SERVER,
                         NULL, client.receive_vpp());
@@ -1582,20 +1577,18 @@ wasapi_get_max_channel_count(cubeb * ctx
 
 int
 wasapi_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * latency_frames)
 {
   if (params.format != CUBEB_SAMPLE_FLOAT32NE && params.format != CUBEB_SAMPLE_S16NE) {
     return CUBEB_ERROR_INVALID_FORMAT;
   }
 
-  ERole role = pref_to_role(params.prefs);
-
   com_ptr<IMMDevice> device;
-  HRESULT hr = get_default_endpoint(device, eRender, role);
+  HRESULT hr = get_default_endpoint(device, eRender);
   if (FAILED(hr)) {
     LOG("Could not get default endpoint: %lx", hr);
     return CUBEB_ERROR;
   }
 
   com_ptr<IAudioClient> client;
   hr = device->Activate(__uuidof(IAudioClient),
                         CLSCTX_INPROC_SERVER,
@@ -1625,17 +1618,17 @@ wasapi_get_min_latency(cubeb * ctx, cube
 
   return CUBEB_OK;
 }
 
 int
 wasapi_get_preferred_sample_rate(cubeb * ctx, uint32_t * rate)
 {
   com_ptr<IMMDevice> device;
-  HRESULT hr = get_default_endpoint(device, eRender, eConsole);
+  HRESULT hr = get_default_endpoint(device, eRender);
   if (FAILED(hr)) {
     return CUBEB_ERROR;
   }
 
   com_ptr<IAudioClient> client;
   hr = device->Activate(__uuidof(IAudioClient),
                         CLSCTX_INPROC_SERVER,
                         NULL, client.receive_vpp());
@@ -1757,17 +1750,17 @@ int setup_wasapi_stream_one_side(cubeb_s
       if (FAILED(hr)) {
         LOG("Could not get %s endpoint, error: %lx\n", DIRECTION_NAME, hr);
         return CUBEB_ERROR;
       }
     } else {
       // If caller has requested loopback but not specified a device, look for
       // the default render device. Otherwise look for the default device
       // appropriate to the direction.
-      hr = get_default_endpoint(device, is_loopback ? eRender : direction, pref_to_role(stream_params->prefs));
+      hr = get_default_endpoint(device, is_loopback ? eRender : direction);
       if (FAILED(hr)) {
         if (is_loopback) {
           LOG("Could not get default render endpoint for loopback, error: %lx\n", hr);
         } else {
           LOG("Could not get default %s endpoint, error: %lx\n", DIRECTION_NAME, hr);
         }
         return CUBEB_ERROR;
       }
@@ -2059,26 +2052,16 @@ int setup_wasapi_stream(cubeb_stream * s
     // Input is up/down mixed when depacketized in get_input_buffer.
     stm->mix_buffer.resize(
       frames_to_bytes_before_mix(stm, stm->output_buffer_frame_count));
   }
 
   return CUBEB_OK;
 }
 
-ERole
-pref_to_role(cubeb_stream_prefs prefs)
-{
-  if (prefs & CUBEB_STREAM_PREF_VOICE) {
-    return eCommunications;
-  }
-
-  return eConsole;
-}
-
 int
 wasapi_stream_init(cubeb * context, cubeb_stream ** stream,
                    char const * stream_name,
                    cubeb_devid input_device,
                    cubeb_stream_params * input_stream_params,
                    cubeb_devid output_device,
                    cubeb_stream_params * output_stream_params,
                    unsigned int latency_frames, cubeb_data_callback data_callback,
@@ -2094,24 +2077,16 @@ wasapi_stream_init(cubeb * context, cube
   }
 
   std::unique_ptr<cubeb_stream, decltype(&wasapi_stream_destroy)> stm(new cubeb_stream(), wasapi_stream_destroy);
 
   stm->context = context;
   stm->data_callback = data_callback;
   stm->state_callback = state_callback;
   stm->user_ptr = user_ptr;
-
-  if (stm->output_stream_params.prefs & CUBEB_STREAM_PREF_VOICE ||
-      stm->input_stream_params.prefs & CUBEB_STREAM_PREF_VOICE) {
-    stm->role = eCommunications;
-  } else {
-    stm->role = eConsole;
-  }
-
   if (input_stream_params) {
     stm->input_stream_params = *input_stream_params;
     stm->input_device = utf8_to_wstr(reinterpret_cast<char const *>(input_device));
   }
   if (output_stream_params) {
     stm->output_stream_params = *output_stream_params;
     stm->output_device = utf8_to_wstr(reinterpret_cast<char const *>(output_device));
   }
--- a/mobile/android/geckoview/src/main/AndroidManifest.xml
+++ b/mobile/android/geckoview/src/main/AndroidManifest.xml
@@ -1,16 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="org.mozilla.geckoview">
 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
-    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
 
     <uses-feature
             android:name="android.hardware.location"
             android:required="false"/>
     <uses-feature
             android:name="android.hardware.location.gps"
             android:required="false"/>
     <uses-feature
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1991,51 +1991,16 @@ public class GeckoAppShell {
         }
         final String prop = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
         if (prop == null) {
             return DEFAULT;
         }
         return Integer.parseInt(prop);
     }
 
-    static private int sPreviousAudioMode = -2;
-
-    @WrapForJNI(calledFrom = "any")
-    public static void setCommunicationAudioModeOn(final boolean on) {
-        final AudioManager am = (AudioManager)getApplicationContext()
-                                .getSystemService(Context.AUDIO_SERVICE);
-        if (am == null) {
-            return;
-        }
-
-        if (sPreviousAudioMode == AudioManager.MODE_INVALID) {
-            sPreviousAudioMode = am.getMode();
-        }
-
-        try {
-            if (on)  {
-                Log.e(LOGTAG, "Setting communication mode ON");
-                sPreviousAudioMode = am.getMode();
-                am.startBluetoothSco();
-                am.setBluetoothScoOn(true);
-                am.setMode(AudioManager.MODE_IN_COMMUNICATION);
-            } else {
-                Log.e(LOGTAG, "Setting communication mode OFF");
-                am.setMode(sPreviousAudioMode);
-                sPreviousAudioMode = AudioManager.MODE_INVALID;
-                am.stopBluetoothSco();
-                am.setBluetoothScoOn(false);
-            }
-        } catch (SecurityException e) {
-            Log.e(LOGTAG, "could not set communication mode", e);
-        }
-
-        am.setSpeakerphoneOn(!on);
-    }
-
     private static String getLanguageTag(final Locale locale) {
         final StringBuilder out = new StringBuilder(locale.getLanguage());
         final String country = locale.getCountry();
         final String variant = locale.getVariant();
         if (!TextUtils.isEmpty(country)) {
             out.append('-').append(country);
         }
         if (!TextUtils.isEmpty(variant)) {