Index: media/audio/android/audio_manager_android.cc |
=================================================================== |
--- media/audio/android/audio_manager_android.cc (revision 194385) |
+++ media/audio/android/audio_manager_android.cc (working copy) |
@@ -56,14 +56,13 @@ |
AudioParameters AudioManagerAndroid::GetInputStreamParameters( |
const std::string& device_id) { |
- // TODO(xians): figure out the right input sample rate and buffer size to |
- // achieve the best audio performance for Android devices. |
+ // TODO(leozwang): Android defines the minimal buffer size requirment |
+ // we should use it. |
+ static const int kDefaultBufferSize = 1024; |
// TODO(xians): query the native channel layout for the specific device. |
- static const int kDefaultSampleRate = 16000; |
- static const int kDefaultBufferSize = 1024; |
return AudioParameters( |
AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, |
- kDefaultSampleRate, 16, kDefaultBufferSize); |
+ GetNativeOutputSampleRate(), 16, kDefaultBufferSize); |
Raymond Toy (Google)
2013/05/15 23:19:46
Is it right to set the input sample rate to the ou
leozwang1
2013/05/16 01:11:55
There is no api to query input sampling rate now.
|
} |
AudioOutputStream* AudioManagerAndroid::MakeAudioOutputStream( |
@@ -122,13 +121,12 @@ |
AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( |
const AudioParameters& input_params) { |
- // TODO(xians): figure out the right output sample rate and buffer size to |
- // achieve the best audio performance for Android devices. |
- static const int kDefaultSampleRate = 44100; |
+ // TODO(leozwang): Android defines the minimal buffer size requirment |
+ // we should use it. |
static const int kDefaultBufferSize = 2048; |
ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
- int sample_rate = kDefaultSampleRate; |
+ int sample_rate = GetNativeOutputSampleRate(); |
int buffer_size = kDefaultBufferSize; |
int bits_per_sample = 16; |
int input_channels = 0; |
@@ -139,10 +137,6 @@ |
channel_layout = input_params.channel_layout(); |
input_channels = input_params.input_channels(); |
- // TODO(leozwang): Android defines the minimal buffer size requirment |
- // we should follow it. From Android 4.1, a new audio low latency api |
- // set was introduced and is under development, we want to take advantage |
- // of it. |
buffer_size = std::min(buffer_size, input_params.frames_per_buffer()); |
} |
@@ -178,4 +172,10 @@ |
j_audio_manager_.obj()); |
} |
+int AudioManagerAndroid::GetNativeOutputSampleRate() { |
+ return Java_AudioManagerAndroid_getNativeOutputSampleRate( |
+ base::android::AttachCurrentThread(), |
+ j_audio_manager_.obj()); |
+} |
+ |
} // namespace media |