Skip to content

Commit

Permalink
Fix issue with airpod not getting re-initialized when changing from h…
Browse files Browse the repository at this point in the history
…ands-free

When airpods change from hands-free to full stereo mode, code in the
mac handler was determining that there had been a change in channels
and was bailing on initialization, even when change in channels
works fine for output devices.
  • Loading branch information
roxanneskelly committed Aug 18, 2024
1 parent 0440132 commit 59124ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions build/patches/airpod_fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/modules/audio_device/mac/audio_device_mac.cc b/modules/audio_device/mac/audio_device_mac.cc
index 0a371737b3..e3a902270d 100644
--- a/modules/audio_device/mac/audio_device_mac.cc
+++ b/modules/audio_device/mac/audio_device_mac.cc
@@ -2096,12 +2096,6 @@ int32_t AudioDeviceMac::HandleStreamFormatChange(
return -1;
}

- if (_ptrAudioBuffer && streamFormat.mChannelsPerFrame != _recChannels) {
- RTC_LOG(LS_ERROR) << "Changing channels not supported (mChannelsPerFrame = "
- << streamFormat.mChannelsPerFrame << ")";
- return -1;
- }
-
RTC_LOG(LS_VERBOSE) << "Stream format:";
RTC_LOG(LS_VERBOSE) << "mSampleRate = " << streamFormat.mSampleRate
<< ", mChannelsPerFrame = "
@@ -2115,6 +2109,12 @@ int32_t AudioDeviceMac::HandleStreamFormatChange(
logCAMsg(rtc::LS_VERBOSE, "mFormatID", (const char*)&streamFormat.mFormatID);

if (propertyAddress.mScope == kAudioDevicePropertyScopeInput) {
+ if (_ptrAudioBuffer && streamFormat.mChannelsPerFrame != _recChannels) {
+ RTC_LOG(LS_ERROR) << "Changing channels not supported (mChannelsPerFrame = "
+ << streamFormat.mChannelsPerFrame << ")";
+ return -1;
+ }
+
const int io_block_size_samples = streamFormat.mChannelsPerFrame *
streamFormat.mSampleRate / 100 *
N_BLOCKS_IO;
2 changes: 2 additions & 0 deletions build/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def get_depot_tools(source_dir, fetch=False):
'disable_mute_of_audio_processing.patch',
'crash_on_fatal_error.patch',
'dont_fatal_error_on_audio_device_stop.patch',
'airpod_fixes.patch',
],
'macos_arm64': [
'add_license_dav1d.patch',
Expand All @@ -232,6 +233,7 @@ def get_depot_tools(source_dir, fetch=False):
'disable_mute_of_audio_processing.patch',
'crash_on_fatal_error.patch',
'dont_fatal_error_on_audio_device_stop.patch',
'airpod_fixes.patch',
],
'ios': [
'add_license_dav1d.patch',
Expand Down

0 comments on commit 59124ca

Please sign in to comment.