diff --git a/media/audio/android/aaudio_output.cc b/media/audio/android/aaudio_output.cc index 269aa135341e..36dacb381b69 100644 --- a/media/audio/android/aaudio_output.cc +++ b/media/audio/android/aaudio_output.cc @@ -102,12 +102,16 @@ AAudioOutputStream::AAudioOutputStream(AudioManagerAndroid* manager, switch (params.latency_tag()) { case AudioLatency::LATENCY_EXACT_MS: case AudioLatency::LATENCY_INTERACTIVE: +#define DISABLE_PERFORMANCE_MODE_HACK 1 + +#if !DISABLE_PERFORMANCE_MODE_HACK case AudioLatency::LATENCY_RTC: performance_mode_ = AAUDIO_PERFORMANCE_MODE_LOW_LATENCY; break; case AudioLatency::LATENCY_PLAYBACK: performance_mode_ = AAUDIO_PERFORMANCE_MODE_POWER_SAVING; break; +#endif default: performance_mode_ = AAUDIO_PERFORMANCE_MODE_NONE; } diff --git a/media/audio/android/opensles_input.cc b/media/audio/android/opensles_input.cc index f6e138702687..4a7656b531fe 100644 --- a/media/audio/android/opensles_input.cc +++ b/media/audio/android/opensles_input.cc @@ -36,7 +36,9 @@ OpenSLESInputStream::OpenSLESInputStream(AudioManagerAndroid* audio_manager, const SampleFormat kSampleFormat = kSampleFormatS16; - format_.formatType = SL_DATAFORMAT_PCM; +#if !FORMAT_HACK +LOG(WARNING) << "====bugbug: Using normal Chrome conf==="; +format_.formatType = SL_DATAFORMAT_PCM; format_.numChannels = static_cast(params.channels()); // Provides sampling rate in milliHertz to OpenSLES. format_.samplesPerSec = static_cast(params.sample_rate() * 1000); @@ -44,6 +46,16 @@ OpenSLESInputStream::OpenSLESInputStream(AudioManagerAndroid* audio_manager, SampleFormatToBitsPerChannel(kSampleFormat); format_.endianness = SL_BYTEORDER_LITTLEENDIAN; format_.channelMask = ChannelCountToSLESChannelMask(params.channels()); +#else + LOG(WARNING) << "====bugbug: Using Cobalt hardcoded conf==="; + format_.formatType = SL_ANDROID_DATAFORMAT_PCM_EX; + format_.numChannels = static_cast(params.channels()); + format_.sampleRate = static_cast(params.sample_rate() * 1000); + format_.bitsPerSample = format_.containerSize = SampleFormatToBitsPerChannel(kSampleFormat); + format_.channelMask = SL_SPEAKER_FRONT_CENTER; + format_.endianness = SL_BYTEORDER_LITTLEENDIAN; + format_.representation = SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT; +#endif buffer_size_bytes_ = params.GetBytesPerBuffer(kSampleFormat); hardware_delay_ = base::Seconds(params.frames_per_buffer() / @@ -249,9 +261,17 @@ bool OpenSLESInputStream::CreateRecorder() { // Uses the main microphone tuned for audio communications if effects are // enabled and disables all audio processing if effects are disabled. +#define INPUT_PRESET_HACK 1 + +#if !INPUT_PRESET_HACK SLint32 stream_type = no_effects_ ? SL_ANDROID_RECORDING_PRESET_CAMCORDER : SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION; +#else + // This is how Cobalt/Starboard sets it + SLint32 stream_type = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION; +#endif + LOG_ON_FAILURE_AND_RETURN( (*recorder_config)->SetConfiguration(recorder_config, SL_ANDROID_KEY_RECORDING_PRESET, diff --git a/media/audio/android/opensles_input.h b/media/audio/android/opensles_input.h index f3d63569dc13..b6ebea160426 100644 --- a/media/audio/android/opensles_input.h +++ b/media/audio/android/opensles_input.h @@ -94,7 +94,13 @@ class OpenSLESInputStream : public AudioInputStream { // Buffer queue recorder interface. SLAndroidSimpleBufferQueueItf simple_buffer_queue_; +#define FORMAT_HACK 0 + +#if !FORMAT_HACK SLDataFormat_PCM format_; +#else + SLAndroidDataFormat_PCM_EX format_; +#endif // Audio buffers that are allocated in the constructor based on // info from audio parameters. diff --git a/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java b/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java index 3f6b89d80229..37eb11ae5246 100644 --- a/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java +++ b/media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java @@ -206,7 +206,7 @@ private void setCommunicationAudioModeOnInternal(boolean on) { if (on) { try { - mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); + // mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); } catch (SecurityException e) { logDeviceInfo(); throw e;