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

Unified Diff: media/audio/mac/audio_manager_mac.cc

Issue 14273018: Use the browser UI thread for audio on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix device listener. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/mac/audio_manager_mac.cc
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc
index 3671317ba67ab2b8a1fa3a10611b062170fd145c..c8e4fb573426d9b9905def4e16d841aebd827dea 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -242,10 +242,14 @@ AudioManagerMac::AudioManagerMac()
}
AudioManagerMac::~AudioManagerMac() {
- // It's safe to post a task here since Shutdown() will wait for all tasks to
- // complete before returning.
- GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
- &AudioManagerMac::DestroyDeviceListener, base::Unretained(this)));
+ if (GetMessageLoop()->BelongsToCurrentThread()) {
+ DestroyDeviceListener();
+ } else {
+ // It's safe to post a task here since Shutdown() will wait for all tasks to
+ // complete before returning.
+ GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
+ &AudioManagerMac::DestroyDeviceListener, base::Unretained(this)));
+ }
Shutdown();
}
@@ -545,10 +549,8 @@ void AudioManagerMac::CreateDeviceListener() {
if (!GetDefaultOutputDevice(&current_output_device_))
current_output_device_ = kAudioDeviceUnknown;
- output_device_listener_.reset(new AudioDeviceListenerMac(BindToLoop(
- GetMessageLoop(), base::Bind(
- &AudioManagerMac::HandleDeviceChanges,
- base::Unretained(this)))));
+ output_device_listener_.reset(new AudioDeviceListenerMac(base::Bind(
+ &AudioManagerMac::HandleDeviceChanges, base::Unretained(this))));
}
void AudioManagerMac::DestroyDeviceListener() {

Powered by Google App Engine
This is Rietveld 408576698