| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 current_sample_rate, | 616 current_sample_rate, |
| 617 (unsigned long)current_frames_per_buffer); | 617 (unsigned long)current_frames_per_buffer); |
| 618 | 618 |
| 619 // Sample rate and buffer size are the same, no work to do. | 619 // Sample rate and buffer size are the same, no work to do. |
| 620 if (std::abs(current_sample_rate - session_sample_rate) <= DBL_EPSILON && | 620 if (std::abs(current_sample_rate - session_sample_rate) <= DBL_EPSILON && |
| 621 current_frames_per_buffer == session_frames_per_buffer) { | 621 current_frames_per_buffer == session_frames_per_buffer) { |
| 622 RTCLog(@"Ignoring sample rate change since audio parameters are intact."); | 622 RTCLog(@"Ignoring sample rate change since audio parameters are intact."); |
| 623 return; | 623 return; |
| 624 } | 624 } |
| 625 | 625 |
| 626 // Extra sanity check to ensure that the new sample rate is valid. |
| 627 if (session_sample_rate <= 0.0) { |
| 628 RTCLogError(@"Sample rate is invalid: %f", session_sample_rate); |
| 629 return; |
| 630 } |
| 631 |
| 626 // We need to adjust our format and buffer sizes. | 632 // We need to adjust our format and buffer sizes. |
| 627 // The stream format is about to be changed and it requires that we first | 633 // The stream format is about to be changed and it requires that we first |
| 628 // stop and uninitialize the audio unit to deallocate its resources. | 634 // stop and uninitialize the audio unit to deallocate its resources. |
| 629 RTCLog(@"Stopping and uninitializing audio unit to adjust buffers."); | 635 RTCLog(@"Stopping and uninitializing audio unit to adjust buffers."); |
| 630 bool restart_audio_unit = false; | 636 bool restart_audio_unit = false; |
| 631 if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kStarted) { | 637 if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kStarted) { |
| 632 audio_unit_->Stop(); | 638 audio_unit_->Stop(); |
| 633 restart_audio_unit = true; | 639 restart_audio_unit = true; |
| 634 } | 640 } |
| 635 if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kInitialized) { | 641 if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kInitialized) { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 946 |
| 941 // All I/O should be stopped or paused prior to deactivating the audio | 947 // All I/O should be stopped or paused prior to deactivating the audio |
| 942 // session, hence we deactivate as last action. | 948 // session, hence we deactivate as last action. |
| 943 [session lockForConfiguration]; | 949 [session lockForConfiguration]; |
| 944 UnconfigureAudioSession(); | 950 UnconfigureAudioSession(); |
| 945 [session endWebRTCSession:nil]; | 951 [session endWebRTCSession:nil]; |
| 946 [session unlockForConfiguration]; | 952 [session unlockForConfiguration]; |
| 947 } | 953 } |
| 948 | 954 |
| 949 } // namespace webrtc | 955 } // namespace webrtc |
| OLD | NEW |