| 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" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void* buffer = NULL; | 122 void* buffer = NULL; |
| 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 int frames_filled = 0; | 127 int frames_filled = 0; |
| 128 if (source_callback_) { | 128 if (source_callback_) { |
| 129 uint32 hardware_delay = pulse::GetHardwareLatencyInBytes( | 129 uint32 hardware_delay = pulse::GetHardwareLatencyInBytes( |
| 130 pa_stream_, params_.sample_rate(), | 130 pa_stream_, params_.sample_rate(), |
| 131 params_.GetBytesPerFrame()); | 131 params_.GetBytesPerFrame()); |
| 132 source_callback_->WaitTillDataReady(); | |
| 133 frames_filled = source_callback_->OnMoreData( | 132 frames_filled = source_callback_->OnMoreData( |
| 134 audio_bus_.get(), AudioBuffersState(0, hardware_delay)); | 133 audio_bus_.get(), AudioBuffersState(0, hardware_delay)); |
| 135 } | 134 } |
| 136 | 135 |
| 137 // Zero any unfilled data so it plays back as silence. | 136 // Zero any unfilled data so it plays back as silence. |
| 138 if (frames_filled < audio_bus_->frames()) { | 137 if (frames_filled < audio_bus_->frames()) { |
| 139 audio_bus_->ZeroFramesPartial( | 138 audio_bus_->ZeroFramesPartial( |
| 140 frames_filled, audio_bus_->frames() - frames_filled); | 139 frames_filled, audio_bus_->frames() - frames_filled); |
| 141 } | 140 } |
| 142 | 141 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 volume_ = static_cast<float>(volume); | 207 volume_ = static_cast<float>(volume); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void PulseAudioOutputStream::GetVolume(double* volume) { | 210 void PulseAudioOutputStream::GetVolume(double* volume) { |
| 212 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); | 211 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); |
| 213 | 212 |
| 214 *volume = volume_; | 213 *volume = volume_; |
| 215 } | 214 } |
| 216 | 215 |
| 217 } // namespace media | 216 } // namespace media |
| OLD | NEW |