Commit 90b67d69 authored by davej@chromium.org's avatar davej@chromium.org

SetIOAllowed when stopping worker audio threads

Stopping a thread is considered "IO" since it "may" take a long time.  In the case with these audio threads, they are already idle, so stopping should not block.

BUG=chromium-os:11110
TEST=(none)

Review URL: http://codereview.chromium.org/6254016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72235 0039d316-1c4b-4281-b951-d872f2087c98
parent 39098666
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/task.h" #include "base/task.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h" #include "chrome/browser/browser_thread.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
...@@ -51,6 +52,11 @@ AudioMixerAlsa::AudioMixerAlsa() ...@@ -51,6 +52,11 @@ AudioMixerAlsa::AudioMixerAlsa()
AudioMixerAlsa::~AudioMixerAlsa() { AudioMixerAlsa::~AudioMixerAlsa() {
FreeAlsaMixer(); FreeAlsaMixer();
if (thread_ != NULL) { if (thread_ != NULL) {
// A ScopedAllowIO object is required to join the thread when calling Stop.
// The worker thread should be idle at this time.
// See http://crosbug.com/11110 for discussion.
base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join;
thread_->Stop(); thread_->Stop();
thread_.reset(); thread_.reset();
} }
...@@ -301,7 +307,7 @@ void AudioMixerAlsa::DoSetVolumeMute(double pref_volume, int pref_mute) { ...@@ -301,7 +307,7 @@ void AudioMixerAlsa::DoSetVolumeMute(double pref_volume, int pref_mute) {
save_volume_ = pref_volume; save_volume_ = pref_volume;
DoSetVolumeDb_Locked(min_volume_); DoSetVolumeDb_Locked(min_volume_);
} else { } else {
DoSetVolumeDb_Locked(pref_volume); DoSetVolumeDb_Locked(pref_volume);
} }
SetElementMuted_Locked(elem_master_, mute); SetElementMuted_Locked(elem_master_, mute);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/task.h" #include "base/task.h"
#include "base/threading/thread_restrictions.h"
namespace chromeos { namespace chromeos {
...@@ -59,6 +60,11 @@ AudioMixerPulse::AudioMixerPulse() ...@@ -59,6 +60,11 @@ AudioMixerPulse::AudioMixerPulse()
AudioMixerPulse::~AudioMixerPulse() { AudioMixerPulse::~AudioMixerPulse() {
PulseAudioFree(); PulseAudioFree();
if (thread_ != NULL) { if (thread_ != NULL) {
// A ScopedAllowIO object is required to join the thread when calling Stop.
// The worker thread should be idle at this time.
// See http://crosbug.com/11110 for discussion.
base::ThreadRestrictions::ScopedAllowIO allow_io_for_thread_join;
thread_->Stop(); thread_->Stop();
thread_.reset(); thread_.reset();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment