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

Side by Side 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: style fixes 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // TODO(tkchin): Figure out if this is really necessary. 629 // TODO(tkchin): Figure out if this is really necessary.
630 if (!self.inputAvailable) { 630 if (!self.inputAvailable) {
631 RTCLogError(@"No audio input path is available!"); 631 RTCLogError(@"No audio input path is available!");
632 [self unconfigureWebRTCSession:nil]; 632 [self unconfigureWebRTCSession:nil];
633 if (outError) { 633 if (outError) {
634 *outError = [self configurationErrorWithDescription:@"No input path."]; 634 *outError = [self configurationErrorWithDescription:@"No input path."];
635 } 635 }
636 return NO; 636 return NO;
637 } 637 }
638 638
639 // It can happen (e.g. in combination with BT devices) that the attempt to set
640 // the preferred sample rate for WebRTC (48kHz) fails. If so, make a new
641 // configuration attempt using the sample rate that worked using the active
642 // audio session. A typical case is that only 8 or 16kHz can be set, e.g. in
643 // combination with BT headsets. Using this "trick" seems to avoid a state
644 // where Core Audio asks for a different number of audio frames than what the
645 // session's I/O buffer duration corresponds to.
646 // TODO(henrika): this fix resolves bugs.webrtc.org/6004 but it has only been
647 // tested on a limited set of iOS devices and BT devices.
648 double sessionSampleRate = self.sampleRate;
649 double preferredSampleRate = webRTCConfig.sampleRate;
650 if (sessionSampleRate != preferredSampleRate) {
651 RTCLogWarning(
652 @"Current sample rate (%.2f) is not the preferred rate (%.2f)",
653 sessionSampleRate, preferredSampleRate);
654 if (![self setPreferredSampleRate:sessionSampleRate
655 error:&error]) {
656 RTCLogError(@"Failed to set preferred sample rate: %@",
657 error.localizedDescription);
658 if (outError) {
659 *outError = error;
660 }
661 }
662 }
663
639 return YES; 664 return YES;
640 } 665 }
641 666
642 - (BOOL)unconfigureWebRTCSession:(NSError **)outError { 667 - (BOOL)unconfigureWebRTCSession:(NSError **)outError {
643 if (outError) { 668 if (outError) {
644 *outError = nil; 669 *outError = nil;
645 } 670 }
646 if (![self checkLock:outError]) { 671 if (![self checkLock:outError]) {
647 return NO; 672 return NO;
648 } 673 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 - (void)notifyDidStopPlayOrRecord { 788 - (void)notifyDidStopPlayOrRecord {
764 for (auto delegate : self.delegates) { 789 for (auto delegate : self.delegates) {
765 SEL sel = @selector(audioSessionDidStopPlayOrRecord:); 790 SEL sel = @selector(audioSessionDidStopPlayOrRecord:);
766 if ([delegate respondsToSelector:sel]) { 791 if ([delegate respondsToSelector:sel]) {
767 [delegate audioSessionDidStopPlayOrRecord:self]; 792 [delegate audioSessionDidStopPlayOrRecord:self];
768 } 793 }
769 } 794 }
770 } 795 }
771 796
772 @end 797 @end
OLDNEW
« 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