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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // NOTE: |bytes_to_fill| may be larger than |requested_bytes| now, this is | 127 // NOTE: |bytes_to_fill| may be larger than |requested_bytes| now, this is |
128 // okay since pa_stream_begin_write() is the authoritative source on how | 128 // okay since pa_stream_begin_write() is the authoritative source on how |
129 // much can be written. | 129 // much can be written. |
130 | 130 |
131 int frames_filled = 0; | 131 int frames_filled = 0; |
132 if (source_callback_) { | 132 if (source_callback_) { |
133 const uint32 hardware_delay = pulse::GetHardwareLatencyInBytes( | 133 const uint32 hardware_delay = pulse::GetHardwareLatencyInBytes( |
134 pa_stream_, params_.sample_rate(), params_.GetBytesPerFrame()); | 134 pa_stream_, params_.sample_rate(), params_.GetBytesPerFrame()); |
135 frames_filled = source_callback_->OnMoreData( | 135 frames_filled = source_callback_->OnMoreData( |
136 audio_bus_.get(), AudioBuffersState(0, hardware_delay)); | 136 audio_bus_.get(), hardware_delay); |
137 | 137 |
138 // Zero any unfilled data so it plays back as silence. | 138 // Zero any unfilled data so it plays back as silence. |
139 if (frames_filled < audio_bus_->frames()) { | 139 if (frames_filled < audio_bus_->frames()) { |
140 audio_bus_->ZeroFramesPartial( | 140 audio_bus_->ZeroFramesPartial( |
141 frames_filled, audio_bus_->frames() - frames_filled); | 141 frames_filled, audio_bus_->frames() - frames_filled); |
142 } | 142 } |
143 | 143 |
144 // Note: If this ever changes to output raw float the data must be clipped | 144 // 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. | 145 // and sanitized since it may come from an untrusted source such as NaCl. |
146 audio_bus_->Scale(volume_); | 146 audio_bus_->Scale(volume_); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 volume_ = static_cast<float>(volume); | 228 volume_ = static_cast<float>(volume); |
229 } | 229 } |
230 | 230 |
231 void PulseAudioOutputStream::GetVolume(double* volume) { | 231 void PulseAudioOutputStream::GetVolume(double* volume) { |
232 DCHECK(thread_checker_.CalledOnValidThread()); | 232 DCHECK(thread_checker_.CalledOnValidThread()); |
233 | 233 |
234 *volume = volume_; | 234 *volume = volume_; |
235 } | 235 } |
236 | 236 |
237 } // namespace media | 237 } // namespace media |
OLD | NEW |