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

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

Issue 187693006: Always PostTask device change notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 6 years, 9 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 | « no previous file | no next file » | 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 79ebe609ea9f4daba77e89c0dcc4354e5bb3c0e5..6db1ed483e1a5b7b279718d28c7ee97e8ee982c1 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -566,8 +566,13 @@ AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream(
// Lazily create the audio device listener on the first stream creation.
if (!output_device_listener_) {
- output_device_listener_.reset(new AudioDeviceListenerMac(base::Bind(
- &AudioManagerMac::HandleDeviceChanges, base::Unretained(this))));
+ // NOTE: Use BindToCurrentLoop() to ensure the callback is always PostTask'd
+ // even if OSX calls us on the right thread. Some CoreAudio drivers will
+ // fire the callbacks during stream creation, leading to re-entrancy issues
+ // otherwise. See http://crbug.com/349604
+ output_device_listener_.reset(
+ new AudioDeviceListenerMac(BindToCurrentLoop(base::Bind(
+ &AudioManagerMac::HandleDeviceChanges, base::Unretained(this)))));
// Only set the current output device for the default device.
if (device_id == AudioManagerBase::kDefaultDeviceId || device_id.empty())
current_output_device_ = device;
@@ -698,13 +703,8 @@ void AudioManagerMac::ShutdownOnAudioThread() {
}
void AudioManagerMac::HandleDeviceChanges() {
- if (!GetTaskRunner()->BelongsToCurrentThread()) {
- GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
- &AudioManagerMac::HandleDeviceChanges, base::Unretained(this)));
- return;
- }
-
- int new_sample_rate = HardwareSampleRate();
+ DCHECK(GetTaskRunner()->BelongsToCurrentThread());
+ const int new_sample_rate = HardwareSampleRate();
AudioDeviceID new_output_device;
GetDefaultOutputDevice(&new_output_device);
« 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