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

Side by Side Diff: chrome/browser/chromeos/audio_mixer_pulse.cc

Issue 6254016: SetIOAllowed when stopping worker audio threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos
Patch Set: formatting Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/audio_mixer_alsa.cc ('k') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/audio_mixer_pulse.h" 5 #include "chrome/browser/chromeos/audio_mixer_pulse.h"
6 6
7 #include <pulse/pulseaudio.h> 7 #include <pulse/pulseaudio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/task.h" 10 #include "base/task.h"
11 #include "base/threading/thread_restrictions.h"
11 12
12 namespace chromeos { 13 namespace chromeos {
13 14
14 // Using asynchronous versions of the threaded PulseAudio API, as well 15 // Using asynchronous versions of the threaded PulseAudio API, as well
15 // as a worker thread so gets, sets, and the init sequence do not block the 16 // as a worker thread so gets, sets, and the init sequence do not block the
16 // calling thread. GetVolume() and IsMute() can still be called synchronously 17 // calling thread. GetVolume() and IsMute() can still be called synchronously
17 // if needed, but take a bit longer (~2ms vs ~0.3ms). 18 // if needed, but take a bit longer (~2ms vs ~0.3ms).
18 // 19 //
19 // Set calls just return without waiting. If you must guarantee the value has 20 // Set calls just return without waiting. If you must guarantee the value has
20 // been set before continuing, immediately call the blocking Get version to 21 // been set before continuing, immediately call the blocking Get version to
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 last_channels_(0), 53 last_channels_(0),
53 mainloop_lock_count_(0), 54 mainloop_lock_count_(0),
54 mixer_state_(UNINITIALIZED), 55 mixer_state_(UNINITIALIZED),
55 pa_context_(NULL), 56 pa_context_(NULL),
56 pa_mainloop_(NULL) { 57 pa_mainloop_(NULL) {
57 } 58 }
58 59
59 AudioMixerPulse::~AudioMixerPulse() { 60 AudioMixerPulse::~AudioMixerPulse() {
60 PulseAudioFree(); 61 PulseAudioFree();
61 if (thread_ != NULL) { 62 if (thread_ != NULL) {
63 // A ScopedAllowIO object is required to join the thread when calling Stop.
64 // The worker thread should be idle at this time.
65 // See http://crosbug.com/11110 for discussion.
66 base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join;
67
62 thread_->Stop(); 68 thread_->Stop();
63 thread_.reset(); 69 thread_.reset();
64 } 70 }
65 } 71 }
66 72
67 void AudioMixerPulse::Init(InitDoneCallback* callback) { 73 void AudioMixerPulse::Init(InitDoneCallback* callback) {
68 DCHECK(callback); 74 DCHECK(callback);
69 if (!InitThread()) { 75 if (!InitThread()) {
70 callback->Run(false); 76 callback->Run(false);
71 delete callback; 77 delete callback;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return false; 462 return false;
457 if (!pa_mainloop_) 463 if (!pa_mainloop_)
458 return false; 464 return false;
459 pa_threaded_mainloop_lock(pa_mainloop_); 465 pa_threaded_mainloop_lock(pa_mainloop_);
460 ++mainloop_lock_count_; 466 ++mainloop_lock_count_;
461 return true; 467 return true;
462 } 468 }
463 469
464 } // namespace chromeos 470 } // namespace chromeos
465 471
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/audio_mixer_alsa.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698