Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: media/audio/android/audio_manager_android.cc

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/android/audio_manager_android.h ('k') | media/audio/audio_input_volume_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/android/audio_manager_android.cc
diff --git a/media/audio/android/audio_manager_android.cc b/media/audio/android/audio_manager_android.cc
index 93296d7b41fc86741a5a50726c226ef59ebaa50c..80e1a27ed434930cd4ea2345e9f953a8b7dc5c18 100644
--- a/media/audio/android/audio_manager_android.cc
+++ b/media/audio/android/audio_manager_android.cc
@@ -8,8 +8,9 @@
#include "media/audio/android/opensles_input.h"
#include "media/audio/android/opensles_output.h"
#include "media/audio/audio_manager.h"
-#include "media/audio/audio_util.h"
+#include "media/audio/audio_parameters.h"
#include "media/audio/fake_audio_input_stream.h"
+#include "media/base/channel_layout.h"
namespace media {
@@ -43,20 +44,16 @@ void AudioManagerAndroid::GetAudioInputDeviceNames(
media::AudioDeviceName(kDefaultDeviceName, kDefaultDeviceId));
}
-AudioParameters
-AudioManagerAndroid::GetPreferredLowLatencyOutputStreamParameters(
- const AudioParameters& input_params) {
- // 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.
- int buffer_size = GetAudioHardwareBufferSize();
- if (input_params.frames_per_buffer() < buffer_size)
- buffer_size = input_params.frames_per_buffer();
-
+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(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, input_params.channel_layout(),
- input_params.sample_rate(), 16, buffer_size);
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
+ kDefaultSampleRate, 16, kDefaultBufferSize);
}
AudioOutputStream* AudioManagerAndroid::MakeLinearOutputStream(
@@ -83,4 +80,35 @@ AudioInputStream* AudioManagerAndroid::MakeLowLatencyInputStream(
return new OpenSLESInputStream(this, params);
}
+AudioParameters AudioManagerAndroid::GetPreferredOutputStreamParameters(
+ const AudioParameters& input_params) {
+ // TODO(xians): figure out the right output sample rate and sample rate to
+ // achieve the best audio performance for Android devices.
+ static const int kDefaultSampleRate = 16000;
+ static const int kDefaultBufferSize = 1024;
+
+ ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
+ int sample_rate = kDefaultSampleRate;
+ int buffer_size = kDefaultBufferSize;
+ int bits_per_sample = 16;
+ int input_channels = 0;
+ if (input_params.IsValid()) {
+ // Use the client's input parameters if they are valid.
+ sample_rate = input_params.sample_rate();
+ bits_per_sample = input_params.bits_per_sample();
+ 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());
+ }
+
+ return AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels,
+ sample_rate, bits_per_sample, buffer_size);
+}
+
} // namespace media
« no previous file with comments | « media/audio/android/audio_manager_android.h ('k') | media/audio/audio_input_volume_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698