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 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 WaitForOperationCompletion(pa_mainloop_, operation); | 220 WaitForOperationCompletion(pa_mainloop_, operation); |
221 | 221 |
222 operation = pa_stream_cork(pa_stream_, 1, &pulse::StreamSuccessCallback, | 222 operation = pa_stream_cork(pa_stream_, 1, &pulse::StreamSuccessCallback, |
223 pa_mainloop_); | 223 pa_mainloop_); |
224 WaitForOperationCompletion(pa_mainloop_, operation); | 224 WaitForOperationCompletion(pa_mainloop_, operation); |
225 } | 225 } |
226 | 226 |
227 void PulseAudioOutputStream::SetVolume(double volume) { | 227 void PulseAudioOutputStream::SetVolume(double volume) { |
228 DCHECK(thread_checker_.CalledOnValidThread()); | 228 DCHECK(thread_checker_.CalledOnValidThread()); |
229 | 229 |
| 230 // Waiting for the main loop lock will ensure outstanding callbacks have |
| 231 // completed and |volume_| is not accessed from them. |
| 232 AutoPulseLock auto_lock(pa_mainloop_); |
230 volume_ = static_cast<float>(volume); | 233 volume_ = static_cast<float>(volume); |
231 } | 234 } |
232 | 235 |
233 void PulseAudioOutputStream::GetVolume(double* volume) { | 236 void PulseAudioOutputStream::GetVolume(double* volume) { |
234 DCHECK(thread_checker_.CalledOnValidThread()); | 237 DCHECK(thread_checker_.CalledOnValidThread()); |
235 | 238 |
236 *volume = volume_; | 239 *volume = volume_; |
237 } | 240 } |
238 | 241 |
239 } // namespace media | 242 } // namespace media |
OLD | NEW |