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

Unified Diff: media/audio/pulse/pulse_output.cc

Issue 2469023002: Support floating-point audio output for Linux (Closed)
Patch Set: Address review comments Created 4 years, 1 month 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 | « no previous file | media/audio/pulse/pulse_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/pulse/pulse_output.cc
diff --git a/media/audio/pulse/pulse_output.cc b/media/audio/pulse/pulse_output.cc
index f86860571a03fca4390c4149704888b5c3630d55..5efa040c0d1b96a712a77cc309badbeef9db4f2a 100644
--- a/media/audio/pulse/pulse_output.cc
+++ b/media/audio/pulse/pulse_output.cc
@@ -12,6 +12,7 @@
#include "media/audio/audio_device_description.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/pulse/pulse_util.h"
+#include "media/base/audio_sample_types.h"
namespace media {
@@ -43,7 +44,14 @@ void PulseAudioOutputStream::StreamRequestCallback(pa_stream* s, size_t len,
PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params,
const std::string& device_id,
AudioManagerBase* manager)
- : params_(params),
+ : params_(AudioParameters(params.format(),
+ params.channel_layout(),
+ params.sample_rate(),
+ // Ignore the given bits per sample. We
+ // want 32 because we're outputting
+ // floats.
+ 32,
+ params.frames_per_buffer())),
device_id_(device_id),
manager_(manager),
pa_context_(NULL),
@@ -143,11 +151,9 @@ void PulseAudioOutputStream::FulfillWriteRequest(size_t requested_bytes) {
frames_filled, audio_bus_->frames() - frames_filled);
}
- // Note: If this ever changes to output raw float the data must be clipped
- // and sanitized since it may come from an untrusted source such as NaCl.
audio_bus_->Scale(volume_);
- audio_bus_->ToInterleaved(
- audio_bus_->frames(), params_.bits_per_sample() / 8, buffer);
+ audio_bus_->ToInterleaved<Float32SampleTypeTraits>(
+ audio_bus_->frames(), reinterpret_cast<float*>(buffer));
} else {
memset(buffer, 0, bytes_to_fill);
}
« no previous file with comments | « no previous file | media/audio/pulse/pulse_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698