Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: media/audio/pulse/pulse_output.cc

Issue 2394483002: Adding syncrhonization to PulseAudioOutputStream::SetVolume (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698