Bug 1626081 - Add a pref to disable the audio output stream routing on Android. r=achronop

Differential Revision: https://phabricator.services.mozilla.com/D74274
This commit is contained in:
Paul Adenot 2020-05-12 08:31:58 +00:00
Родитель c22eb3baf0
Коммит 32d217338f
4 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -52,6 +52,7 @@
#define PREF_CUBEB_LOGGING_LEVEL "media.cubeb.logging_level"
// Hidden pref used by tests to force failure to obtain cubeb context
#define PREF_CUBEB_FORCE_NULL_CONTEXT "media.cubeb.force_null_context"
#define PREF_CUBEB_OUTPUT_VOICE_ROUTING "media.cubeb.output_voice_routing"
// Hidden pref to disable BMO 1427011 experiment; can be removed once proven.
#define PREF_CUBEB_DISABLE_DEVICE_SWITCHING \
"media.cubeb.disable_device_switching"
@ -100,6 +101,7 @@ bool sCubebMTGLatencyPrefSet = false;
bool sAudioStreamInitEverSucceeded = false;
bool sCubebForceNullContext = false;
bool sCubebDisableDeviceSwitching = true;
bool sRouteOutputAsVoice = false;
#ifdef MOZ_CUBEB_REMOTING
bool sCubebSandbox = false;
size_t sAudioIPCPoolSize;
@ -267,6 +269,13 @@ void PrefChanged(const char* aPref, void* aClosure) {
AUDIOIPC_STACK_SIZE_DEFAULT);
}
#endif
else if (strcmp(aPref, PREF_CUBEB_OUTPUT_VOICE_ROUTING) == 0) {
StaticMutexAutoLock lock(sMutex);
sRouteOutputAsVoice = Preferences::GetBool(aPref);
MOZ_LOG(gCubebLog, LogLevel::Verbose,
("%s: %s", PREF_CUBEB_OUTPUT_VOICE_ROUTING,
sRouteOutputAsVoice ? "true" : "false"));
}
}
bool GetFirstStream() {
@ -676,6 +685,8 @@ cubeb_stream_prefs GetDefaultStreamPrefs() {
return CUBEB_STREAM_PREF_NONE;
}
bool RouteOutputAsVoice() { return sRouteOutputAsVoice; }
#ifdef MOZ_WIDGET_ANDROID
uint32_t AndroidGetAudioOutputSampleRate() {
int32_t sample_rate = java::GeckoAppShell::GetAudioOutputSampleRate();

Просмотреть файл

@ -51,6 +51,10 @@ char* GetForcedOutputDevice();
// to switch to "communication mode", which might change audio routing,
// bluetooth communication type, etc.
void SetInCommunication(bool aInCommunication);
// Returns true if the output streams should be routed like a stream containing
// voice data, and not generic audio. This can influence audio processing and
// device selection.
bool RouteOutputAsVoice();
# ifdef MOZ_WIDGET_ANDROID
uint32_t AndroidGetAudioOutputSampleRate();

Просмотреть файл

@ -642,7 +642,8 @@ void AudioCallbackDriver::Init() {
output.layout = static_cast<uint32_t>(channelMap);
output.prefs = CubebUtils::GetDefaultStreamPrefs();
#if !defined(XP_WIN)
if (mInputDevicePreference == CUBEB_DEVICE_PREF_VOICE) {
if (mInputDevicePreference == CUBEB_DEVICE_PREF_VOICE &&
CubebUtils::RouteOutputAsVoice()) {
output.prefs |= static_cast<cubeb_stream_prefs>(CUBEB_STREAM_PREF_VOICE);
}
#endif
@ -671,6 +672,10 @@ void AudioCallbackDriver::Init() {
input = output;
input.channels = mInputChannelCount;
input.layout = CUBEB_LAYOUT_UNDEFINED;
input.prefs = CubebUtils::GetDefaultStreamPrefs();
if (mInputDevicePreference == CUBEB_DEVICE_PREF_VOICE) {
input.prefs |= static_cast<cubeb_stream_prefs>(CUBEB_STREAM_PREF_VOICE);
}
cubeb_stream* stream = nullptr;
bool inputWanted = mInputChannelCount > 0;

Просмотреть файл

@ -583,6 +583,8 @@ pref("media.cubeb.logging_level", "");
pref("media.cubeb.backend", "audiounit-rust");
#endif
pref("media.cubeb.output_voice_routing", true);
// GraphRunner (fixed MediaTrackGraph thread) control
pref("media.audiograph.single_thread.enabled", true);