Chromium Code Reviews| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 int frame_size = GetAudioLowLatencyOutputFrameSize(); |
| 129 // Return the optimal size as a multiple of the low latency frame | 129 // Return the optimal size as a multiple of the low latency frame |
|
DaleCurtis
2013/06/17 21:49:53
Also delete this comment and just return GetAudio
wjia(left Chromium)
2013/06/17 22:04:10
Done.
| |
| 130 // size that is close to the target frame size. | 130 // size that is close to the target frame size. |
| 131 return ((kDefaultOutputBufferSize + frame_size / 2) / frame_size) * | 131 return frame_size; |
| 132 frame_size; | |
| 133 } else { | 132 } else { |
| 134 return std::max(kDefaultOutputBufferSize, | 133 return std::max(kDefaultOutputBufferSize, |
| 135 Java_AudioManagerAndroid_getMinOutputFrameSize( | 134 Java_AudioManagerAndroid_getMinOutputFrameSize( |
| 136 base::android::AttachCurrentThread(), | 135 base::android::AttachCurrentThread(), |
| 137 sample_rate, channels)); | 136 sample_rate, channels)); |
| 138 } | 137 } |
| 139 } | 138 } |
| 140 | 139 |
| 141 AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( | 140 AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( |
| 142 const AudioParameters& input_params) { | 141 const AudioParameters& input_params) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 j_audio_manager_.obj()); | 197 j_audio_manager_.obj()); |
| 199 } | 198 } |
| 200 | 199 |
| 201 int AudioManagerAndroid::GetAudioLowLatencyOutputFrameSize() { | 200 int AudioManagerAndroid::GetAudioLowLatencyOutputFrameSize() { |
| 202 return Java_AudioManagerAndroid_getAudioLowLatencyOutputFrameSize( | 201 return Java_AudioManagerAndroid_getAudioLowLatencyOutputFrameSize( |
| 203 base::android::AttachCurrentThread(), | 202 base::android::AttachCurrentThread(), |
| 204 j_audio_manager_.obj()); | 203 j_audio_manager_.obj()); |
| 205 } | 204 } |
| 206 | 205 |
| 207 } // namespace media | 206 } // namespace media |
| OLD | NEW |