| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 int32_t AudioTransportProxy::NeedMorePlayData(const size_t nSamples, | 62 int32_t AudioTransportProxy::NeedMorePlayData(const size_t nSamples, |
| 63 const size_t nBytesPerSample, | 63 const size_t nBytesPerSample, |
| 64 const size_t nChannels, | 64 const size_t nChannels, |
| 65 const uint32_t samplesPerSec, | 65 const uint32_t samplesPerSec, |
| 66 void* audioSamples, | 66 void* audioSamples, |
| 67 size_t& nSamplesOut, | 67 size_t& nSamplesOut, |
| 68 int64_t* elapsed_time_ms, | 68 int64_t* elapsed_time_ms, |
| 69 int64_t* ntp_time_ms) { | 69 int64_t* ntp_time_ms) { |
| 70 RTC_DCHECK_EQ(sizeof(int16_t) * nChannels, nBytesPerSample); | 70 RTC_DCHECK_EQ(sizeof(int16_t) * nChannels, nBytesPerSample); |
| 71 RTC_DCHECK_GE(nChannels, 1u); | 71 RTC_DCHECK_GE(nChannels, 1); |
| 72 RTC_DCHECK_LE(nChannels, 2u); | 72 RTC_DCHECK_LE(nChannels, 2); |
| 73 RTC_DCHECK_GE( | 73 RTC_DCHECK_GE( |
| 74 samplesPerSec, | 74 samplesPerSec, |
| 75 static_cast<uint32_t>(AudioProcessing::NativeRate::kSampleRate8kHz)); | 75 static_cast<uint32_t>(AudioProcessing::NativeRate::kSampleRate8kHz)); |
| 76 | 76 |
| 77 // 100 = 1 second / data duration (10 ms). | 77 // 100 = 1 second / data duration (10 ms). |
| 78 RTC_DCHECK_EQ(nSamples * 100, samplesPerSec); | 78 RTC_DCHECK_EQ(nSamples * 100, samplesPerSec); |
| 79 RTC_DCHECK_LE(nBytesPerSample * nSamples * nChannels, | 79 RTC_DCHECK_LE(nBytesPerSample * nSamples * nChannels, |
| 80 sizeof(AudioFrame::data_)); | 80 sizeof(AudioFrame::data_)); |
| 81 | 81 |
| 82 mixer_->Mix(nChannels, &mixed_frame_); | 82 mixer_->Mix(nChannels, &mixed_frame_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 void AudioTransportProxy::PullRenderData(int bits_per_sample, | 106 void AudioTransportProxy::PullRenderData(int bits_per_sample, |
| 107 int sample_rate, | 107 int sample_rate, |
| 108 size_t number_of_channels, | 108 size_t number_of_channels, |
| 109 size_t number_of_frames, | 109 size_t number_of_frames, |
| 110 void* audio_data, | 110 void* audio_data, |
| 111 int64_t* elapsed_time_ms, | 111 int64_t* elapsed_time_ms, |
| 112 int64_t* ntp_time_ms) { | 112 int64_t* ntp_time_ms) { |
| 113 RTC_DCHECK_EQ(static_cast<size_t>(bits_per_sample), 16); | 113 RTC_DCHECK_EQ(static_cast<size_t>(bits_per_sample), 16); |
| 114 RTC_DCHECK_GE(number_of_channels, 1u); | 114 RTC_DCHECK_GE(number_of_channels, 1); |
| 115 RTC_DCHECK_LE(number_of_channels, 2u); | 115 RTC_DCHECK_LE(number_of_channels, 2); |
| 116 RTC_DCHECK_GE(static_cast<int>(sample_rate), | 116 RTC_DCHECK_GE(static_cast<int>(sample_rate), |
| 117 AudioProcessing::NativeRate::kSampleRate8kHz); | 117 AudioProcessing::NativeRate::kSampleRate8kHz); |
| 118 | 118 |
| 119 // 100 = 1 second / data duration (10 ms). | 119 // 100 = 1 second / data duration (10 ms). |
| 120 RTC_DCHECK_EQ(static_cast<int>(number_of_frames * 100), sample_rate); | 120 RTC_DCHECK_EQ(static_cast<int>(number_of_frames * 100), sample_rate); |
| 121 | 121 |
| 122 // 8 = bits per byte. | 122 // 8 = bits per byte. |
| 123 RTC_DCHECK_LE(bits_per_sample / 8 * number_of_frames * number_of_channels, | 123 RTC_DCHECK_LE(bits_per_sample / 8 * number_of_frames * number_of_channels, |
| 124 sizeof(AudioFrame::data_)); | 124 sizeof(AudioFrame::data_)); |
| 125 mixer_->Mix(number_of_channels, &mixed_frame_); | 125 mixer_->Mix(number_of_channels, &mixed_frame_); |
| 126 *elapsed_time_ms = mixed_frame_.elapsed_time_ms_; | 126 *elapsed_time_ms = mixed_frame_.elapsed_time_ms_; |
| 127 *ntp_time_ms = mixed_frame_.ntp_time_ms_; | 127 *ntp_time_ms = mixed_frame_.ntp_time_ms_; |
| 128 | 128 |
| 129 const auto output_samples = Resample(mixed_frame_, sample_rate, &resampler_, | 129 const auto output_samples = Resample(mixed_frame_, sample_rate, &resampler_, |
| 130 static_cast<int16_t*>(audio_data)); | 130 static_cast<int16_t*>(audio_data)); |
| 131 RTC_DCHECK_EQ(output_samples, number_of_channels * number_of_frames); | 131 RTC_DCHECK_EQ(output_samples, number_of_channels * number_of_frames); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace webrtc | 134 } // namespace webrtc |
| OLD | NEW |