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

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: Comments. Created 7 years, 6 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
« no previous file with comments | « media/audio/mac/audio_device_listener_mac.cc ('k') | media/audio/mock_audio_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33dcff08d129dc163a87da2d8a0adf99a5868f3e..5cbdd5fefd66ba6bee7af3ce9f2182f529e18bb4 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -236,16 +236,21 @@ AudioManagerMac::AudioManagerMac()
SetMaxOutputStreamsAllowed(kMaxOutputStreams);
// Task must be posted last to avoid races from handing out "this" to the
- // audio thread.
+ // audio thread. Always PostTask even if we're on the right thread since
+ // AudioManager creation is on the startup path and this may be slow.
GetMessageLoop()->PostTask(FROM_HERE, base::Bind(
&AudioManagerMac::CreateDeviceListener, base::Unretained(this)));
}
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();
}
@@ -550,10 +555,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() {
« no previous file with comments | « media/audio/mac/audio_device_listener_mac.cc ('k') | media/audio/mock_audio_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698