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

Side by Side Diff: media/audio/pulse/pulse_output.cc

Issue 2469023002: Support floating-point audio output for Linux (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
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/pulse/pulse_output.h" 5 #include "media/audio/pulse/pulse_output.h"
6 6
7 #include <pulse/pulseaudio.h> 7 #include <pulse/pulseaudio.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "media/audio/audio_device_description.h" 12 #include "media/audio/audio_device_description.h"
13 #include "media/audio/audio_manager_base.h" 13 #include "media/audio/audio_manager_base.h"
14 #include "media/audio/pulse/pulse_util.h" 14 #include "media/audio/pulse/pulse_util.h"
15 #include "media/base/audio_sample_types.h"
15 16
16 namespace media { 17 namespace media {
17 18
18 using pulse::AutoPulseLock; 19 using pulse::AutoPulseLock;
19 using pulse::WaitForOperationCompletion; 20 using pulse::WaitForOperationCompletion;
20 21
21 // static, pa_stream_notify_cb 22 // static, pa_stream_notify_cb
22 void PulseAudioOutputStream::StreamNotifyCallback(pa_stream* s, void* p_this) { 23 void PulseAudioOutputStream::StreamNotifyCallback(pa_stream* s, void* p_this) {
23 PulseAudioOutputStream* stream = static_cast<PulseAudioOutputStream*>(p_this); 24 PulseAudioOutputStream* stream = static_cast<PulseAudioOutputStream*>(p_this);
24 25
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 140
140 // Zero any unfilled data so it plays back as silence. 141 // Zero any unfilled data so it plays back as silence.
141 if (frames_filled < audio_bus_->frames()) { 142 if (frames_filled < audio_bus_->frames()) {
142 audio_bus_->ZeroFramesPartial( 143 audio_bus_->ZeroFramesPartial(
143 frames_filled, audio_bus_->frames() - frames_filled); 144 frames_filled, audio_bus_->frames() - frames_filled);
144 } 145 }
145 146
146 // Note: If this ever changes to output raw float the data must be clipped 147 // Note: If this ever changes to output raw float the data must be clipped
147 // and sanitized since it may come from an untrusted source such as NaCl. 148 // and sanitized since it may come from an untrusted source such as NaCl.
148 audio_bus_->Scale(volume_); 149 audio_bus_->Scale(volume_);
150 #if 0
149 audio_bus_->ToInterleaved( 151 audio_bus_->ToInterleaved(
150 audio_bus_->frames(), params_.bits_per_sample() / 8, buffer); 152 audio_bus_->frames(), params_.bits_per_sample() / 8, buffer);
153 #else
154 audio_bus_->ToInterleaved<Float32SampleTypeTraits>(
155 audio_bus_->frames(), reinterpret_cast<float*>(buffer));
DaleCurtis 2016/11/01 18:51:37 is buffer allocated correctly?
156 #endif
151 } else { 157 } else {
152 memset(buffer, 0, bytes_to_fill); 158 memset(buffer, 0, bytes_to_fill);
153 } 159 }
154 160
155 if (pa_stream_write(pa_stream_, buffer, bytes_to_fill, NULL, 0LL, 161 if (pa_stream_write(pa_stream_, buffer, bytes_to_fill, NULL, 0LL,
156 PA_SEEK_RELATIVE) < 0) { 162 PA_SEEK_RELATIVE) < 0) {
157 if (source_callback_) { 163 if (source_callback_) {
158 source_callback_->OnError(this); 164 source_callback_->OnError(this);
159 } 165 }
160 } 166 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 volume_ = static_cast<float>(volume); 239 volume_ = static_cast<float>(volume);
234 } 240 }
235 241
236 void PulseAudioOutputStream::GetVolume(double* volume) { 242 void PulseAudioOutputStream::GetVolume(double* volume) {
237 DCHECK(thread_checker_.CalledOnValidThread()); 243 DCHECK(thread_checker_.CalledOnValidThread());
238 244
239 *volume = volume_; 245 *volume = volume_;
240 } 246 }
241 247
242 } // namespace media 248 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698