| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/audio/android/audio_manager_android.h" | 5 #include "media/audio/android/audio_manager_android.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "jni/AudioManagerAndroid_jni.h" | 8 #include "jni/AudioManagerAndroid_jni.h" |
| 9 #include "media/audio/android/opensles_input.h" | 9 #include "media/audio/android/opensles_input.h" |
| 10 #include "media/audio/android/opensles_output.h" | 10 #include "media/audio/android/opensles_output.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 AudioInputStream* AudioManagerAndroid::MakeLowLatencyInputStream( | 119 AudioInputStream* AudioManagerAndroid::MakeLowLatencyInputStream( |
| 120 const AudioParameters& params, const std::string& device_id) { | 120 const AudioParameters& params, const std::string& device_id) { |
| 121 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 121 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
| 122 return new OpenSLESInputStream(this, params); | 122 return new OpenSLESInputStream(this, params); |
| 123 } | 123 } |
| 124 | 124 |
| 125 int AudioManagerAndroid::GetOptimalOutputFrameSize(int sample_rate, | 125 int AudioManagerAndroid::GetOptimalOutputFrameSize(int sample_rate, |
| 126 int channels) { | 126 int channels) { |
| 127 if (IsAudioLowLatencySupported()) { | 127 if (IsAudioLowLatencySupported()) { |
| 128 int frame_size = GetAudioLowLatencyOutputFrameSize(); | 128 return GetAudioLowLatencyOutputFrameSize(); |
| 129 // Return the optimal size as a multiple of the low latency frame | |
| 130 // size that is close to the target frame size. | |
| 131 return ((kDefaultOutputBufferSize + frame_size / 2) / frame_size) * | |
| 132 frame_size; | |
| 133 } else { | 129 } else { |
| 134 return std::max(kDefaultOutputBufferSize, | 130 return std::max(kDefaultOutputBufferSize, |
| 135 Java_AudioManagerAndroid_getMinOutputFrameSize( | 131 Java_AudioManagerAndroid_getMinOutputFrameSize( |
| 136 base::android::AttachCurrentThread(), | 132 base::android::AttachCurrentThread(), |
| 137 sample_rate, channels)); | 133 sample_rate, channels)); |
| 138 } | 134 } |
| 139 } | 135 } |
| 140 | 136 |
| 141 AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( | 137 AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( |
| 142 const AudioParameters& input_params) { | 138 const AudioParameters& input_params) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 j_audio_manager_.obj()); | 194 j_audio_manager_.obj()); |
| 199 } | 195 } |
| 200 | 196 |
| 201 int AudioManagerAndroid::GetAudioLowLatencyOutputFrameSize() { | 197 int AudioManagerAndroid::GetAudioLowLatencyOutputFrameSize() { |
| 202 return Java_AudioManagerAndroid_getAudioLowLatencyOutputFrameSize( | 198 return Java_AudioManagerAndroid_getAudioLowLatencyOutputFrameSize( |
| 203 base::android::AttachCurrentThread(), | 199 base::android::AttachCurrentThread(), |
| 204 j_audio_manager_.obj()); | 200 j_audio_manager_.obj()); |
| 205 } | 201 } |
| 206 | 202 |
| 207 } // namespace media | 203 } // namespace media |
| OLD | NEW |