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

Unified Diff: media/audio/pulse/audio_manager_pulse.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/pulse/audio_manager_pulse.h ('k') | media/audio/win/audio_manager_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/pulse/audio_manager_pulse.cc
diff --git a/media/audio/pulse/audio_manager_pulse.cc b/media/audio/pulse/audio_manager_pulse.cc
index f448fcea59d22d041f75af5d87d56d4a9598cb37..1217ecf498d7e7dc251e6bd532a7ed4b4a0a7192 100644
--- a/media/audio/pulse/audio_manager_pulse.cc
+++ b/media/audio/pulse/audio_manager_pulse.cc
@@ -11,12 +11,13 @@
#include "base/nix/xdg_util.h"
#include "base/process_util.h"
#include "base/stl_util.h"
-#include "media/audio/audio_util.h"
+#include "media/audio/audio_parameters.h"
#include "media/audio/linux/audio_manager_linux.h"
#include "media/audio/pulse/pulse_input.h"
#include "media/audio/pulse/pulse_output.h"
#include "media/audio/pulse/pulse_stubs.h"
#include "media/audio/pulse/pulse_util.h"
+#include "media/base/channel_layout.h"
using media_audio_pulse::kModulePulse;
using media_audio_pulse::InitializeStubs;
@@ -90,6 +91,16 @@ void AudioManagerPulse::GetAudioInputDeviceNames(
}
}
+AudioParameters AudioManagerPulse::GetInputStreamParameters(
+ const std::string& device_id) {
+ static const int kDefaultInputBufferSize = 1024;
+
+ // TODO(xians): add support for querying native channel layout for pulse.
+ return AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
+ GetNativeSampleRate(), 16, kDefaultInputBufferSize);
+}
+
AudioOutputStream* AudioManagerPulse::MakeLinearOutputStream(
const AudioParameters& params) {
DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
@@ -114,6 +125,25 @@ AudioInputStream* AudioManagerPulse::MakeLowLatencyInputStream(
return MakeInputStream(params, device_id);
}
+AudioParameters AudioManagerPulse::GetPreferredOutputStreamParameters(
+ const AudioParameters& input_params) {
+ static const int kDefaultOutputBufferSize = 512;
+
+ ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
+ int buffer_size = kDefaultOutputBufferSize;
+ int bits_per_sample = 16;
+ int input_channels = 0;
+ if (input_params.IsValid()) {
+ bits_per_sample = input_params.bits_per_sample();
+ channel_layout = input_params.channel_layout();
+ input_channels = input_params.input_channels();
+ buffer_size = std::min(buffer_size, input_params.frames_per_buffer());
+ }
+ return AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels,
+ GetNativeSampleRate(), bits_per_sample, buffer_size);
+}
+
AudioOutputStream* AudioManagerPulse::MakeOutputStream(
const AudioParameters& params) {
return new PulseAudioOutputStream(params, this);
@@ -125,20 +155,6 @@ AudioInputStream* AudioManagerPulse::MakeInputStream(
input_mainloop_, input_context_);
}
-AudioParameters AudioManagerPulse::GetPreferredLowLatencyOutputStreamParameters(
- const AudioParameters& input_params) {
- // TODO(xians): figure out the optimized buffer size for the Pulse IO.
- int buffer_size = GetAudioHardwareBufferSize();
- if (input_params.frames_per_buffer() < buffer_size)
- buffer_size = input_params.frames_per_buffer();
-
- // TODO(dalecurtis): This should include bits per channel and channel layout
- // eventually.
- return AudioParameters(
- AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(),
- input_params.sample_rate(), 16, buffer_size);
-}
-
int AudioManagerPulse::GetNativeSampleRate() {
DCHECK(input_mainloop_);
DCHECK(input_context_);
« no previous file with comments | « media/audio/pulse/audio_manager_pulse.h ('k') | media/audio/win/audio_manager_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698