OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 RTC_DCHECK(!simple_buffer_queue_); | 198 RTC_DCHECK(!simple_buffer_queue_); |
199 RTC_CHECK(audio_device_buffer_); | 199 RTC_CHECK(audio_device_buffer_); |
200 // Create a modified audio buffer class which allows us to ask for any number | 200 // Create a modified audio buffer class which allows us to ask for any number |
201 // of samples (and not only multiple of 10ms) to match the native OpenSL ES | 201 // of samples (and not only multiple of 10ms) to match the native OpenSL ES |
202 // buffer size. The native buffer size corresponds to the | 202 // buffer size. The native buffer size corresponds to the |
203 // PROPERTY_OUTPUT_FRAMES_PER_BUFFER property which is the number of audio | 203 // PROPERTY_OUTPUT_FRAMES_PER_BUFFER property which is the number of audio |
204 // frames that the HAL (Hardware Abstraction Layer) buffer can hold. It is | 204 // frames that the HAL (Hardware Abstraction Layer) buffer can hold. It is |
205 // recommended to construct audio buffers so that they contain an exact | 205 // recommended to construct audio buffers so that they contain an exact |
206 // multiple of this number. If so, callbacks will occur at regular intervals, | 206 // multiple of this number. If so, callbacks will occur at regular intervals, |
207 // which reduces jitter. | 207 // which reduces jitter. |
208 ALOGD("native buffer size: %" PRIuS, audio_parameters_.GetBytesPerBuffer()); | 208 const size_t buffer_size_in_bytes = audio_parameters_.GetBytesPerBuffer(); |
| 209 ALOGD("native buffer size: %" PRIuS, buffer_size_in_bytes); |
209 ALOGD("native buffer size in ms: %.2f", | 210 ALOGD("native buffer size in ms: %.2f", |
210 audio_parameters_.GetBufferSizeInMilliseconds()); | 211 audio_parameters_.GetBufferSizeInMilliseconds()); |
211 fine_audio_buffer_.reset(new FineAudioBuffer( | 212 fine_audio_buffer_.reset(new FineAudioBuffer( |
212 audio_device_buffer_, audio_parameters_.GetBytesPerBuffer(), | 213 audio_device_buffer_, buffer_size_in_bytes, |
213 audio_parameters_.sample_rate())); | 214 audio_parameters_.sample_rate())); |
214 // Each buffer must be of this size to avoid unnecessary memcpy while caching | 215 // Allocated memory for audio buffers. |
215 // data between successive callbacks. | |
216 const size_t required_buffer_size = | |
217 fine_audio_buffer_->RequiredPlayoutBufferSizeBytes(); | |
218 ALOGD("required buffer size: %" PRIuS, required_buffer_size); | |
219 for (int i = 0; i < kNumOfOpenSLESBuffers; ++i) { | 216 for (int i = 0; i < kNumOfOpenSLESBuffers; ++i) { |
220 audio_buffers_[i].reset(new SLint8[required_buffer_size]); | 217 audio_buffers_[i].reset(new SLint8[buffer_size_in_bytes]); |
221 } | 218 } |
222 } | 219 } |
223 | 220 |
224 bool OpenSLESPlayer::ObtainEngineInterface() { | 221 bool OpenSLESPlayer::ObtainEngineInterface() { |
225 ALOGD("ObtainEngineInterface"); | 222 ALOGD("ObtainEngineInterface"); |
226 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 223 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
227 if (engine_) | 224 if (engine_) |
228 return true; | 225 return true; |
229 // Get access to (or create if not already existing) the global OpenSL Engine | 226 // Get access to (or create if not already existing) the global OpenSL Engine |
230 // object. | 227 // object. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 RTC_DCHECK(player_); | 414 RTC_DCHECK(player_); |
418 SLuint32 state; | 415 SLuint32 state; |
419 SLresult err = (*player_)->GetPlayState(player_, &state); | 416 SLresult err = (*player_)->GetPlayState(player_, &state); |
420 if (SL_RESULT_SUCCESS != err) { | 417 if (SL_RESULT_SUCCESS != err) { |
421 ALOGE("GetPlayState failed: %d", err); | 418 ALOGE("GetPlayState failed: %d", err); |
422 } | 419 } |
423 return state; | 420 return state; |
424 } | 421 } |
425 | 422 |
426 } // namespace webrtc | 423 } // namespace webrtc |
OLD | NEW |