OLD | NEW |
---|---|
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 Loading... | |
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 session_sample_rate = self.sampleRate; | |
tkchin_webrtc
2016/06/15 21:21:46
in ObjC methods, use ObjC style rules. Camel case
henrika_webrtc
2016/06/16 12:12:26
Done.
| |
649 double preferred_sample_rate = webRTCConfig.sampleRate; | |
650 if (session_sample_rate != preferred_sample_rate) { | |
651 RTCLogWarning( | |
tkchin_webrtc
2016/06/15 21:21:46
fyi I've made it to that ObjC files are now 100cha
henrika_webrtc
2016/06/16 12:12:26
Got it. Keeping 80 here to be consistent with the
| |
652 @"Current sample rate (%.2f) is not the preferred rate (%.2f)", | |
653 session_sample_rate, preferred_sample_rate); | |
654 if (![self setPreferredSampleRate:session_sample_rate | |
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 Loading... | |
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 |
OLD | NEW |