OLD | NEW |
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 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
11 #include "media/audio/audio_parameters.h" | 11 #include "media/audio/audio_parameters.h" |
12 #include "media/audio/audio_util.h" | |
13 #include "media/audio/pulse/pulse_util.h" | 12 #include "media/audio/pulse/pulse_util.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, pa_stream_notify_cb | 19 // static, pa_stream_notify_cb |
21 void PulseAudioOutputStream::StreamNotifyCallback(pa_stream* s, void* p_this) { | 20 void PulseAudioOutputStream::StreamNotifyCallback(pa_stream* s, void* p_this) { |
22 PulseAudioOutputStream* stream = static_cast<PulseAudioOutputStream*>(p_this); | 21 PulseAudioOutputStream* stream = static_cast<PulseAudioOutputStream*>(p_this); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 135 } |
137 | 136 |
138 // Zero any unfilled data so it plays back as silence. | 137 // Zero any unfilled data so it plays back as silence. |
139 if (frames_filled < audio_bus_->frames()) { | 138 if (frames_filled < audio_bus_->frames()) { |
140 audio_bus_->ZeroFramesPartial( | 139 audio_bus_->ZeroFramesPartial( |
141 frames_filled, audio_bus_->frames() - frames_filled); | 140 frames_filled, audio_bus_->frames() - frames_filled); |
142 } | 141 } |
143 | 142 |
144 // Note: If this ever changes to output raw float the data must be clipped | 143 // Note: If this ever changes to output raw float the data must be clipped |
145 // and sanitized since it may come from an untrusted source such as NaCl. | 144 // and sanitized since it may come from an untrusted source such as NaCl. |
| 145 audio_bus_->AdjustVolume(volume_); |
146 audio_bus_->ToInterleaved( | 146 audio_bus_->ToInterleaved( |
147 audio_bus_->frames(), params_.bits_per_sample() / 8, buffer); | 147 audio_bus_->frames(), params_.bits_per_sample() / 8, buffer); |
148 media::AdjustVolume(buffer, bytes_to_fill, params_.channels(), | |
149 params_.bits_per_sample() / 8, volume_); | |
150 | 148 |
151 if (pa_stream_write(pa_stream_, buffer, bytes_to_fill, NULL, 0LL, | 149 if (pa_stream_write(pa_stream_, buffer, bytes_to_fill, NULL, 0LL, |
152 PA_SEEK_RELATIVE) < 0) { | 150 PA_SEEK_RELATIVE) < 0) { |
153 if (source_callback_) { | 151 if (source_callback_) { |
154 source_callback_->OnError(this); | 152 source_callback_->OnError(this); |
155 } | 153 } |
156 } | 154 } |
157 | 155 |
158 bytes_remaining -= bytes_to_fill; | 156 bytes_remaining -= bytes_to_fill; |
159 } | 157 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 volume_ = static_cast<float>(volume); | 208 volume_ = static_cast<float>(volume); |
211 } | 209 } |
212 | 210 |
213 void PulseAudioOutputStream::GetVolume(double* volume) { | 211 void PulseAudioOutputStream::GetVolume(double* volume) { |
214 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); | 212 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); |
215 | 213 |
216 *volume = volume_; | 214 *volume = volume_; |
217 } | 215 } |
218 | 216 |
219 } // namespace media | 217 } // namespace media |
OLD | NEW |