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

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

Issue 13726011: Add vector_math::FMUL. Replace audio_util::AdjustVolume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix NaCl. Add unittests. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_unified.h" 5 #include "media/audio/pulse/pulse_unified.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "media/audio/audio_manager_base.h" 9 #include "media/audio/audio_manager_base.h"
10 #include "media/audio/audio_parameters.h" 10 #include "media/audio/audio_parameters.h"
11 #include "media/audio/audio_util.h"
12 #include "media/audio/pulse/pulse_util.h" 11 #include "media/audio/pulse/pulse_util.h"
13 #include "media/base/seekable_buffer.h" 12 #include "media/base/seekable_buffer.h"
14 13
15 namespace media { 14 namespace media {
16 15
17 using pulse::AutoPulseLock; 16 using pulse::AutoPulseLock;
18 using pulse::WaitForOperationCompletion; 17 using pulse::WaitForOperationCompletion;
19 18
20 static const int kFifoSizeInPackets = 10; 19 static const int kFifoSizeInPackets = 10;
21 20
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 167 }
169 168
170 // Zero the unfilled data so it plays back as silence. 169 // Zero the unfilled data so it plays back as silence.
171 if (frames_filled < output_bus_->frames()) { 170 if (frames_filled < output_bus_->frames()) {
172 output_bus_->ZeroFramesPartial( 171 output_bus_->ZeroFramesPartial(
173 frames_filled, output_bus_->frames() - frames_filled); 172 frames_filled, output_bus_->frames() - frames_filled);
174 } 173 }
175 174
176 // Note: If this ever changes to output raw float the data must be clipped 175 // Note: If this ever changes to output raw float the data must be clipped
177 // and sanitized since it may come from an untrusted source such as NaCl. 176 // and sanitized since it may come from an untrusted source such as NaCl.
177 output_bus_->AdjustVolume(volume_);
178 output_bus_->ToInterleaved( 178 output_bus_->ToInterleaved(
179 output_bus_->frames(), params_.bits_per_sample() / 8, buffer); 179 output_bus_->frames(), params_.bits_per_sample() / 8, buffer);
180 media::AdjustVolume(buffer, requested_bytes, params_.channels(),
181 params_.bits_per_sample() / 8, volume_);
182 180
183 if (pa_stream_write(output_stream_, buffer, requested_bytes, NULL, 0LL, 181 if (pa_stream_write(output_stream_, buffer, requested_bytes, NULL, 0LL,
184 PA_SEEK_RELATIVE) < 0) { 182 PA_SEEK_RELATIVE) < 0) {
185 if (source_callback_) { 183 if (source_callback_) {
186 source_callback_->OnError(this); 184 source_callback_->OnError(this);
187 } 185 }
188 } 186 }
189 } 187 }
190 188
191 void PulseAudioUnifiedStream::ReadData() { 189 void PulseAudioUnifiedStream::ReadData() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 volume_ = static_cast<float>(volume); 282 volume_ = static_cast<float>(volume);
285 } 283 }
286 284
287 void PulseAudioUnifiedStream::GetVolume(double* volume) { 285 void PulseAudioUnifiedStream::GetVolume(double* volume) {
288 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); 286 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
289 287
290 *volume = volume_; 288 *volume = volume_;
291 } 289 }
292 290
293 } // namespace media 291 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698