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 "media/audio/android/opensles_input.h" | 8 #include "media/audio/android/opensles_input.h" |
9 #include "media/audio/android/opensles_output.h" | 9 #include "media/audio/android/opensles_output.h" |
10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 AudioInputStream* AudioManagerAndroid::MakeLowLatencyInputStream( | 78 AudioInputStream* AudioManagerAndroid::MakeLowLatencyInputStream( |
79 const AudioParameters& params, const std::string& device_id) { | 79 const AudioParameters& params, const std::string& device_id) { |
80 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); | 80 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); |
81 return new OpenSLESInputStream(this, params); | 81 return new OpenSLESInputStream(this, params); |
82 } | 82 } |
83 | 83 |
84 AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( | 84 AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters( |
85 const AudioParameters& input_params) { | 85 const AudioParameters& input_params) { |
86 // TODO(xians): figure out the right output sample rate and sample rate to | 86 // TODO(xians): figure out the right output sample rate and buffer size to |
87 // achieve the best audio performance for Android devices. | 87 // achieve the best audio performance for Android devices. |
88 static const int kDefaultSampleRate = 16000; | 88 static const int kDefaultSampleRate = 44100; |
89 static const int kDefaultBufferSize = 1024; | 89 static const int kDefaultBufferSize = 2048; |
90 | 90 |
91 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; | 91 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
92 int sample_rate = kDefaultSampleRate; | 92 int sample_rate = kDefaultSampleRate; |
93 int buffer_size = kDefaultBufferSize; | 93 int buffer_size = kDefaultBufferSize; |
94 int bits_per_sample = 16; | 94 int bits_per_sample = 16; |
95 int input_channels = 0; | 95 int input_channels = 0; |
96 if (input_params.IsValid()) { | 96 if (input_params.IsValid()) { |
97 // Use the client's input parameters if they are valid. | 97 // Use the client's input parameters if they are valid. |
98 sample_rate = input_params.sample_rate(); | 98 sample_rate = input_params.sample_rate(); |
99 bits_per_sample = input_params.bits_per_sample(); | 99 bits_per_sample = input_params.bits_per_sample(); |
(...skipping 10 matching lines...) Expand all Loading... |
110 int user_buffer_size = GetUserBufferSize(); | 110 int user_buffer_size = GetUserBufferSize(); |
111 if (user_buffer_size) | 111 if (user_buffer_size) |
112 buffer_size = user_buffer_size; | 112 buffer_size = user_buffer_size; |
113 | 113 |
114 return AudioParameters( | 114 return AudioParameters( |
115 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, | 115 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, |
116 sample_rate, bits_per_sample, buffer_size); | 116 sample_rate, bits_per_sample, buffer_size); |
117 } | 117 } |
118 | 118 |
119 } // namespace media | 119 } // namespace media |
OLD | NEW |