| 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 |
| 11 #include "webrtc/modules/audio_device/android/opensles_player.h" | 11 #include "webrtc/modules/audio_device/android/opensles_player.h" |
| 12 | 12 |
| 13 #include <android/log.h> | 13 #include <android/log.h> |
| 14 | 14 |
| 15 #include "webrtc/base/arraysize.h" | 15 #include "webrtc/base/arraysize.h" |
| 16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/base/format_macros.h" |
| 17 #include "webrtc/modules/audio_device/android/audio_manager.h" | 18 #include "webrtc/modules/audio_device/android/audio_manager.h" |
| 18 #include "webrtc/modules/audio_device/android/fine_audio_buffer.h" | 19 #include "webrtc/modules/audio_device/android/fine_audio_buffer.h" |
| 19 | 20 |
| 20 #define TAG "OpenSLESPlayer" | 21 #define TAG "OpenSLESPlayer" |
| 21 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) | 22 #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) |
| 22 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) | 23 #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) |
| 23 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) | 24 #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) |
| 24 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) | 25 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) |
| 25 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) | 26 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) |
| 26 | 27 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return -1; | 169 return -1; |
| 169 } | 170 } |
| 170 | 171 |
| 171 void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { | 172 void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { |
| 172 ALOGD("AttachAudioBuffer"); | 173 ALOGD("AttachAudioBuffer"); |
| 173 DCHECK(thread_checker_.CalledOnValidThread()); | 174 DCHECK(thread_checker_.CalledOnValidThread()); |
| 174 audio_device_buffer_ = audioBuffer; | 175 audio_device_buffer_ = audioBuffer; |
| 175 const int sample_rate_hz = audio_parameters_.sample_rate(); | 176 const int sample_rate_hz = audio_parameters_.sample_rate(); |
| 176 ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz); | 177 ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz); |
| 177 audio_device_buffer_->SetPlayoutSampleRate(sample_rate_hz); | 178 audio_device_buffer_->SetPlayoutSampleRate(sample_rate_hz); |
| 178 const int channels = audio_parameters_.channels(); | 179 const size_t channels = audio_parameters_.channels(); |
| 179 ALOGD("SetPlayoutChannels(%d)", channels); | 180 ALOGD("SetPlayoutChannels(%" PRIuS ")", channels); |
| 180 audio_device_buffer_->SetPlayoutChannels(channels); | 181 audio_device_buffer_->SetPlayoutChannels(channels); |
| 181 CHECK(audio_device_buffer_); | 182 CHECK(audio_device_buffer_); |
| 182 AllocateDataBuffers(); | 183 AllocateDataBuffers(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 SLDataFormat_PCM OpenSLESPlayer::CreatePCMConfiguration(int channels, | 186 SLDataFormat_PCM OpenSLESPlayer::CreatePCMConfiguration(size_t channels, |
| 186 int sample_rate, | 187 int sample_rate, |
| 187 int bits_per_sample) { | 188 int bits_per_sample) { |
| 188 ALOGD("CreatePCMConfiguration"); | 189 ALOGD("CreatePCMConfiguration"); |
| 189 CHECK_EQ(bits_per_sample, SL_PCMSAMPLEFORMAT_FIXED_16); | 190 CHECK_EQ(bits_per_sample, SL_PCMSAMPLEFORMAT_FIXED_16); |
| 190 SLDataFormat_PCM format; | 191 SLDataFormat_PCM format; |
| 191 format.formatType = SL_DATAFORMAT_PCM; | 192 format.formatType = SL_DATAFORMAT_PCM; |
| 192 format.numChannels = static_cast<SLuint32>(channels); | 193 format.numChannels = static_cast<SLuint32>(channels); |
| 193 // Note that, the unit of sample rate is actually in milliHertz and not Hertz. | 194 // Note that, the unit of sample rate is actually in milliHertz and not Hertz. |
| 194 switch (sample_rate) { | 195 switch (sample_rate) { |
| 195 case 8000: | 196 case 8000: |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 DCHECK(player_); | 434 DCHECK(player_); |
| 434 SLuint32 state; | 435 SLuint32 state; |
| 435 SLresult err = (*player_)->GetPlayState(player_, &state); | 436 SLresult err = (*player_)->GetPlayState(player_, &state); |
| 436 if (SL_RESULT_SUCCESS != err) { | 437 if (SL_RESULT_SUCCESS != err) { |
| 437 ALOGE("GetPlayState failed: %d", err); | 438 ALOGE("GetPlayState failed: %d", err); |
| 438 } | 439 } |
| 439 return state; | 440 return state; |
| 440 } | 441 } |
| 441 | 442 |
| 442 } // namespace webrtc | 443 } // namespace webrtc |
| OLD | NEW |