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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 RTC_DCHECK_EQ(playout_parameters_.GetBytesPerBuffer(), | 620 RTC_DCHECK_EQ(playout_parameters_.GetBytesPerBuffer(), |
621 record_parameters_.GetBytesPerBuffer()); | 621 record_parameters_.GetBytesPerBuffer()); |
622 | 622 |
623 // Update the ADB parameters since the sample rate might have changed. | 623 // Update the ADB parameters since the sample rate might have changed. |
624 UpdateAudioDeviceBuffer(); | 624 UpdateAudioDeviceBuffer(); |
625 | 625 |
626 // Create a modified audio buffer class which allows us to ask for, | 626 // Create a modified audio buffer class which allows us to ask for, |
627 // or deliver, any number of samples (and not only multiple of 10ms) to match | 627 // or deliver, any number of samples (and not only multiple of 10ms) to match |
628 // the native audio unit buffer size. | 628 // the native audio unit buffer size. |
629 RTC_DCHECK(audio_device_buffer_); | 629 RTC_DCHECK(audio_device_buffer_); |
| 630 const size_t buffer_size_in_bytes = playout_parameters_.GetBytesPerBuffer(); |
630 fine_audio_buffer_.reset(new FineAudioBuffer( | 631 fine_audio_buffer_.reset(new FineAudioBuffer( |
631 audio_device_buffer_, playout_parameters_.GetBytesPerBuffer(), | 632 audio_device_buffer_, buffer_size_in_bytes, |
632 playout_parameters_.sample_rate())); | 633 playout_parameters_.sample_rate())); |
633 | 634 playout_audio_buffer_.reset(new SInt8[buffer_size_in_bytes]); |
634 // The extra/temporary playoutbuffer must be of this size to avoid | |
635 // unnecessary memcpy while caching data between successive callbacks. | |
636 const int required_playout_buffer_size = | |
637 fine_audio_buffer_->RequiredPlayoutBufferSizeBytes(); | |
638 LOG(LS_INFO) << " required playout buffer size: " | |
639 << required_playout_buffer_size; | |
640 playout_audio_buffer_.reset(new SInt8[required_playout_buffer_size]); | |
641 | 635 |
642 // Allocate AudioBuffers to be used as storage for the received audio. | 636 // Allocate AudioBuffers to be used as storage for the received audio. |
643 // The AudioBufferList structure works as a placeholder for the | 637 // The AudioBufferList structure works as a placeholder for the |
644 // AudioBuffer structure, which holds a pointer to the actual data buffer | 638 // AudioBuffer structure, which holds a pointer to the actual data buffer |
645 // in |record_audio_buffer_|. Recorded audio will be rendered into this memory | 639 // in |record_audio_buffer_|. Recorded audio will be rendered into this memory |
646 // at each input callback when calling AudioUnitRender(). | 640 // at each input callback when calling AudioUnitRender(). |
647 const int data_byte_size = record_parameters_.GetBytesPerBuffer(); | 641 const int data_byte_size = record_parameters_.GetBytesPerBuffer(); |
648 record_audio_buffer_.reset(new SInt8[data_byte_size]); | 642 record_audio_buffer_.reset(new SInt8[data_byte_size]); |
649 memset(record_audio_buffer_.get(), 0, data_byte_size); | 643 memset(record_audio_buffer_.get(), 0, data_byte_size); |
650 audio_record_buffer_list_.mNumberBuffers = 1; | 644 audio_record_buffer_list_.mNumberBuffers = 1; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 824 |
831 // All I/O should be stopped or paused prior to deactivating the audio | 825 // All I/O should be stopped or paused prior to deactivating the audio |
832 // session, hence we deactivate as last action. | 826 // session, hence we deactivate as last action. |
833 [session lockForConfiguration]; | 827 [session lockForConfiguration]; |
834 UnconfigureAudioSession(); | 828 UnconfigureAudioSession(); |
835 [session endWebRTCSession:nil]; | 829 [session endWebRTCSession:nil]; |
836 [session unlockForConfiguration]; | 830 [session unlockForConfiguration]; |
837 } | 831 } |
838 | 832 |
839 } // namespace webrtc | 833 } // namespace webrtc |
OLD | NEW |