From 16f6336ae391c695948fd545711777ac52e4d008 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Wed, 31 Oct 2018 14:22:23 +0000 Subject: [PATCH] Bug 1502313 - Remove concurrent audio input device limit. r=padenot The limit only applied within a child process. However, within a child process we already share cubeb stream when requesting the same device multiple times, and disallow capturing from more than one device at a time. This limit no longer has any effect. Differential Revision: https://phabricator.services.mozilla.com/D10339 --HG-- extra : moz-landing-system : lando --- dom/media/CubebUtils.cpp | 17 +------------- dom/media/CubebUtils.h | 1 - dom/media/tests/mochitest/head.js | 3 +-- dom/media/webrtc/MediaEngineWebRTCAudio.cpp | 25 +-------------------- modules/libpref/init/all.js | 5 ----- 5 files changed, 3 insertions(+), 48 deletions(-) diff --git a/dom/media/CubebUtils.cpp b/dom/media/CubebUtils.cpp index 0e857d46b36e..989e5d0c6cc8 100644 --- a/dom/media/CubebUtils.cpp +++ b/dom/media/CubebUtils.cpp @@ -38,8 +38,6 @@ #define PREF_CUBEB_OUTPUT_DEVICE "media.cubeb.output_device" #define PREF_CUBEB_LATENCY_PLAYBACK "media.cubeb_latency_playback_ms" #define PREF_CUBEB_LATENCY_MSG "media.cubeb_latency_msg_frames" -// This only works when audio remoting is active, and pulseaudio is the backend. -#define PREF_CUBEB_MAX_INPUT_STREAMS "media.cubeb_max_input_streams" // Allows to get something non-default for the preferred sample-rate, to allow // troubleshooting in the field and testing. #define PREF_CUBEB_FORCE_SAMPLE_RATE "media.cubeb.force_sample_rate" @@ -131,9 +129,6 @@ cubeb* sCubebContext; double sVolumeScale = 1.0; uint32_t sCubebPlaybackLatencyInMilliseconds = 100; uint32_t sCubebMSGLatencyInFrames = 512; -// Maximum number of audio input streams that can be open at once. This pref is -// only used when remoting is on, and we're using PulseAudio as a backend. -uint32_t sCubebMaxInputStreams = 1; // If sCubebForcedSampleRate is zero, PreferredSampleRate will return the // preferred sample-rate for the audio backend in use. Otherwise, it will be // used as the preferred sample-rate. @@ -238,9 +233,6 @@ void PrefChanged(const char* aPref, void* aClosure) // We don't want to limit the upper limit too much, so that people can // experiment. sCubebMSGLatencyInFrames = std::min(std::max(value, 128), 1e6); - } else if (strcmp(aPref, PREF_CUBEB_MAX_INPUT_STREAMS) == 0) { - StaticMutexAutoLock lock(sMutex); - sCubebMaxInputStreams = Preferences::GetUint(aPref); } else if (strcmp(aPref, PREF_CUBEB_FORCE_SAMPLE_RATE) == 0) { StaticMutexAutoLock lock(sMutex); sCubebForcedSampleRate = Preferences::GetUint(aPref); @@ -571,19 +563,12 @@ uint32_t GetCubebMSGLatencyInFrames(cubeb_stream_params * params) #endif } -uint32_t GetMaxInputStreams() -{ - StaticMutexAutoLock lock(sMutex); - return sCubebMaxInputStreams; -} - static const char* gInitCallbackPrefs[] = { PREF_VOLUME_SCALE, PREF_CUBEB_OUTPUT_DEVICE, PREF_CUBEB_LATENCY_PLAYBACK, PREF_CUBEB_LATENCY_MSG, PREF_CUBEB_BACKEND, PREF_CUBEB_FORCE_NULL_CONTEXT, PREF_CUBEB_SANDBOX, PREF_AUDIOIPC_POOL_SIZE, - PREF_CUBEB_MAX_INPUT_STREAMS, PREF_AUDIOIPC_STACK_SIZE, - nullptr, + PREF_AUDIOIPC_STACK_SIZE, nullptr, }; static const char* gCallbackPrefs[] = { PREF_CUBEB_FORCE_SAMPLE_RATE, diff --git a/dom/media/CubebUtils.h b/dom/media/CubebUtils.h index dd296663870e..eafafd00db22 100644 --- a/dom/media/CubebUtils.h +++ b/dom/media/CubebUtils.h @@ -50,7 +50,6 @@ void GetDeviceCollection(nsTArray>& aDeviceInfos, Side aSide); cubeb_stream_prefs GetDefaultStreamPrefs(); char* GetForcedOutputDevice(); -uint32_t GetMaxInputStreams(); #ifdef MOZ_WIDGET_ANDROID uint32_t AndroidGetAudioOutputSampleRate(); diff --git a/dom/media/tests/mochitest/head.js b/dom/media/tests/mochitest/head.js index d107169a518e..24ac9ed42c41 100644 --- a/dom/media/tests/mochitest/head.js +++ b/dom/media/tests/mochitest/head.js @@ -422,8 +422,7 @@ function setupEnvironment() { ['media.getusermedia.screensharing.enabled', true], ['media.getusermedia.window.focus_source.enabled', false], ['media.recorder.audio_node.enabled', true], - ['media.webaudio.audiocontextoptions-samplerate.enabled', true], - ['media.cubeb_max_input_streams', 10000] + ['media.webaudio.audiocontextoptions-samplerate.enabled', true] ] }; diff --git a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp index b0ecf767afde..bfdd78bd2b5c 100644 --- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp +++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp @@ -32,10 +32,6 @@ using namespace webrtc; #define MAX_CHANNELS 2 #define MAX_SAMPLING_FREQ 48000 // Hz - multiple of 100 -#ifdef MOZ_PULSEAUDIO -static uint32_t sInputStreamsOpen = 0; -#endif - namespace mozilla { #ifdef LOG @@ -656,23 +652,7 @@ MediaEngineWebRTCMicrophoneSource::Start(const RefPtr&) return NS_ERROR_FAILURE; } - // On Linux with PulseAudio, we still only allow a certain number of audio - // input stream in each content process, because of issues related to audio - // remoting and PulseAudio. -#ifdef MOZ_PULSEAUDIO - // When remoting, cubeb reports it's using the "remote" backend instead of the - // backend on the other side of the IPC. - const char* backend = cubeb_get_backend_id(CubebUtils::GetCubebContext()); - if (strstr(backend, "remote") && - sInputStreamsOpen == CubebUtils::GetMaxInputStreams()) { - LOG(("%p Already capturing audio in this process, aborting", this)); - return NS_ERROR_FAILURE; - } - sInputStreamsOpen++; -#endif - - AssertIsOnOwningThread(); mInputProcessing = new AudioInputProcessing( mDeviceMaxChannelCount, mStream, mTrackID, mPrincipal); @@ -711,10 +691,7 @@ MediaEngineWebRTCMicrophoneSource::Stop(const RefPtr&) return NS_OK; } -#ifdef MOZ_PULSEAUDIO - MOZ_ASSERT(sInputStreamsOpen > 0); - sInputStreamsOpen--; -#endif + RefPtr that = this; RefPtr gripGraph = mStream->GraphImpl(); NS_DispatchToMainThread(media::NewRunnableFrom( diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 3e166f2ce9cc..30d4ec22deba 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -635,11 +635,6 @@ pref("media.audioipc.stack_size", 262144); pref("media.cubeb.sandbox", false); #endif -#ifdef XP_LINUX -// Bug 1481152 -pref("media.cubeb_max_input_streams", 1); -#endif - #ifdef MOZ_AV1 pref("media.av1.enabled", false); #endif