| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 RTCLog(@"Configuring audio session for WebRTC."); | 681 RTCLog(@"Configuring audio session for WebRTC."); |
| 682 | 682 |
| 683 // Configure the AVAudioSession and activate it. | 683 // Configure the AVAudioSession and activate it. |
| 684 // Provide an error even if there isn't one so we can log it. | 684 // Provide an error even if there isn't one so we can log it. |
| 685 NSError *error = nil; | 685 NSError *error = nil; |
| 686 RTCAudioSessionConfiguration *webRTCConfig = | 686 RTCAudioSessionConfiguration *webRTCConfig = |
| 687 [RTCAudioSessionConfiguration webRTCConfiguration]; | 687 [RTCAudioSessionConfiguration webRTCConfiguration]; |
| 688 if (![self setConfiguration:webRTCConfig active:YES error:&error]) { | 688 if (![self setConfiguration:webRTCConfig active:YES error:&error]) { |
| 689 RTCLogError(@"Failed to set WebRTC audio configuration: %@", | 689 RTCLogError(@"Failed to set WebRTC audio configuration: %@", |
| 690 error.localizedDescription); | 690 error.localizedDescription); |
| 691 [self unconfigureWebRTCSession:nil]; | 691 // Don't call unconfigureWebRTCSession if the audio session wasn't configure
d successfully |
| 692 if (outError) { | 692 if (outError) { |
| 693 *outError = error; | 693 *outError = error; |
| 694 } | 694 } |
| 695 return NO; | 695 return NO; |
| 696 } | 696 } |
| 697 | 697 |
| 698 // Ensure that the device currently supports audio input. | 698 // Ensure that the device currently supports audio input. |
| 699 // TODO(tkchin): Figure out if this is really necessary. | 699 // TODO(tkchin): Figure out if this is really necessary. |
| 700 if (!self.inputAvailable) { | 700 if (!self.inputAvailable) { |
| 701 RTCLogError(@"No audio input path is available!"); | 701 RTCLogError(@"No audio input path is available!"); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 return; | 780 return; |
| 781 } | 781 } |
| 782 _canPlayOrRecord = canPlayOrRecord; | 782 _canPlayOrRecord = canPlayOrRecord; |
| 783 shouldNotify = YES; | 783 shouldNotify = YES; |
| 784 } | 784 } |
| 785 if (shouldNotify) { | 785 if (shouldNotify) { |
| 786 [self notifyDidChangeCanPlayOrRecord:canPlayOrRecord]; | 786 [self notifyDidChangeCanPlayOrRecord:canPlayOrRecord]; |
| 787 } | 787 } |
| 788 } | 788 } |
| 789 | 789 |
| 790 - (void)audioSessionDidActivate:(AVAudioSession *)session { |
| 791 if (_session != session) { |
| 792 RTCLogError(@"audioSessionDidActivate called on different AVAudioSession"); |
| 793 } |
| 794 [self incrementActivationCount]; |
| 795 self.isActive = YES; |
| 796 } |
| 797 |
| 798 - (void)audioSessionDidDeactivate:(AVAudioSession *)session { |
| 799 if (_session != session) { |
| 800 RTCLogError(@"audioSessionDidDeactivate called on different AVAudioSession")
; |
| 801 } |
| 802 self.isActive = NO; |
| 803 [self decrementActivationCount]; |
| 804 } |
| 805 |
| 790 - (void)notifyDidBeginInterruption { | 806 - (void)notifyDidBeginInterruption { |
| 791 for (auto delegate : self.delegates) { | 807 for (auto delegate : self.delegates) { |
| 792 SEL sel = @selector(audioSessionDidBeginInterruption:); | 808 SEL sel = @selector(audioSessionDidBeginInterruption:); |
| 793 if ([delegate respondsToSelector:sel]) { | 809 if ([delegate respondsToSelector:sel]) { |
| 794 [delegate audioSessionDidBeginInterruption:self]; | 810 [delegate audioSessionDidBeginInterruption:self]; |
| 795 } | 811 } |
| 796 } | 812 } |
| 797 } | 813 } |
| 798 | 814 |
| 799 - (void)notifyDidEndInterruptionWithShouldResumeSession: | 815 - (void)notifyDidEndInterruptionWithShouldResumeSession: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 - (void)notifyDidStopPlayOrRecord { | 874 - (void)notifyDidStopPlayOrRecord { |
| 859 for (auto delegate : self.delegates) { | 875 for (auto delegate : self.delegates) { |
| 860 SEL sel = @selector(audioSessionDidStopPlayOrRecord:); | 876 SEL sel = @selector(audioSessionDidStopPlayOrRecord:); |
| 861 if ([delegate respondsToSelector:sel]) { | 877 if ([delegate respondsToSelector:sel]) { |
| 862 [delegate audioSessionDidStopPlayOrRecord:self]; | 878 [delegate audioSessionDidStopPlayOrRecord:self]; |
| 863 } | 879 } |
| 864 } | 880 } |
| 865 } | 881 } |
| 866 | 882 |
| 867 @end | 883 @end |
| OLD | NEW |