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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 size_t bytes_to_fill = params_.GetBytesPerBuffer(); | 123 size_t bytes_to_fill = params_.GetBytesPerBuffer(); |
124 CHECK_GE(pa_stream_begin_write(pa_stream_, &buffer, &bytes_to_fill), 0); | 124 CHECK_GE(pa_stream_begin_write(pa_stream_, &buffer, &bytes_to_fill), 0); |
125 CHECK_EQ(bytes_to_fill, static_cast<size_t>(params_.GetBytesPerBuffer())); | 125 CHECK_EQ(bytes_to_fill, static_cast<size_t>(params_.GetBytesPerBuffer())); |
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_t hardware_delay = pulse::GetHardwareLatencyInBytes( |
134 pa_stream_, params_.sample_rate(), params_.GetBytesPerFrame()); | 134 pa_stream_, params_.sample_rate(), params_.GetBytesPerFrame()); |
135 frames_filled = | 135 frames_filled = |
136 source_callback_->OnMoreData(audio_bus_.get(), hardware_delay, 0); | 136 source_callback_->OnMoreData(audio_bus_.get(), hardware_delay, 0); |
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 |
(...skipping 84 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 |