Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Unified Diff: webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm

Issue 2063733002: Resolves issue with bad audio using BT headsets on iOS (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: improved comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm
diff --git a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm
index 7ef5110f476a9cf950eaa3cda86dcb721e3ae6e1..86fd176182bf6067fa18d32f5091ac3568cd9a60 100644
--- a/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm
+++ b/webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm
@@ -636,6 +636,42 @@ NSInteger const kRTCAudioSessionErrorConfiguration = -2;
return NO;
}
+ // It can happen (e.g. in combination with BT devices) that the attempt to set
tkchin_webrtc 2016/06/14 19:13:28 It seems like we should do this on route changes,
henrika_webrtc 2016/06/15 13:46:58 But the problem is that it does not work since we
+ // the preferred sample rate for WebRTC (48kHz) fails. If so, disable the
+ // current session and make a new configuration attempt using the sample rate
+ // that worked. A typical case is that only 8 or 16kHz can be set, e.g. in
+ // combination with BT headsets. Using this "trick" seems to avoid a state
+ // where Core Audio asks for a different number of audio frames than what the
+ // session's I/O buffer duration corresponds to.
+ // TODO(henrika): this fix resolves b/29185303 but it has only been tested on
tkchin_webrtc 2016/06/14 19:13:28 Don't reference buganizer in webrtc. File a corres
henrika_webrtc 2016/06/15 13:46:58 Done.
+ // a limited set of iOS devices and BT devices.
+ double session_sample_rate = self.sampleRate;
+ double preferred_sample_rate = webRTCConfig.sampleRate;
+ if (session_sample_rate != preferred_sample_rate) {
+ RTCLogWarning(
+ @"Current sample rate (%.2f) is not the preferred rate (%.2f)",
+ session_sample_rate, preferred_sample_rate);
+ // Perform a second configuration attempt but use a sample rate that is
+ // known to work this time instead (e.g. 8 or 16kHz in combination with BT
+ // headsets).
+ RTCLog(@"Configuring audio session for WebRTC using new sample rate.");
+ [self unconfigureWebRTCSession:nil];
tkchin_webrtc 2016/06/14 19:13:28 this won't work if there are multiple activations
henrika_webrtc 2016/06/15 13:46:58 Missed that. I actually started out by making the
+ webRTCConfig.sampleRate = session_sample_rate;
+ [RTCAudioSessionConfiguration setWebRTCConfiguration:webRTCConfig];
tkchin_webrtc 2016/06/14 19:13:28 I don't think we should set the default because we
henrika_webrtc 2016/06/15 13:46:58 Agree that it is not a clean solution. Will rethin
+ if (![self setConfiguration:webRTCConfig active:YES error:&error]) {
+ RTCLogError(@"Failed to set WebRTC audio configuration: %@",
+ error.localizedDescription);
+ [self unconfigureWebRTCSession:nil];
+ if (outError) {
+ *outError = error;
+ }
+ return NO;
+ }
+ // Restore original WebRTC configuration parameters.
+ webRTCConfig.sampleRate = preferred_sample_rate;
+ [RTCAudioSessionConfiguration setWebRTCConfiguration:webRTCConfig];
+ }
+
return YES;
}
« no previous file with comments | « webrtc/modules/audio_device/ios/audio_device_ios.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698