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

Unified Diff: content/renderer/media/audio_device.cc

Issue 9534002: Stop the AudioDeviceThread when the IO loop goes away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle another edge case Created 8 years, 10 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: content/renderer/media/audio_device.cc
diff --git a/content/renderer/media/audio_device.cc b/content/renderer/media/audio_device.cc
index 3f89e93ced06d84d6e3524353648f45c4abe2a88..c4a10f04f4d09bb209e0c2c15e3cbf815a7b3c83 100644
--- a/content/renderer/media/audio_device.cc
+++ b/content/renderer/media/audio_device.cc
@@ -178,6 +178,11 @@ void AudioDevice::ShutDownOnIOThread() {
stream_id_ = 0;
}
+ // We can run into an issue where ShutDownOnIOThread is called right after
+ // OnStreamCreated is called in cases where Start/Stop are called before we
+ // get the OnStreamCreated callback. To handle that corner case, we call
+ // Stop(). In most cases, the thread will already be stopped.
+ audio_thread_.Stop(MessageLoop::current());
scherkus (not reviewing) 2012/02/29 21:10:15 hold the phone... combined with the change to Wil
tommi (sloooow) - chröme 2012/02/29 21:22:13 We shouldn't do that on the IO thread due to threa
audio_callback_.reset();
}
@@ -218,6 +223,7 @@ void AudioDevice::OnStreamCreated(
return;
}
+ DCHECK(audio_thread_.IsStopped());
audio_callback_.reset(new AudioDevice::AudioThreadCallback(audio_parameters_,
handle, length, callback_));
audio_thread_.Start(audio_callback_.get(), socket_handle, "AudioDevice");
@@ -234,6 +240,8 @@ void AudioDevice::Send(IPC::Message* message) {
}
void AudioDevice::WillDestroyCurrentMessageLoop() {
+ LOG(ERROR) << "IO loop going away before the audio device has been stopped";
+ audio_thread_.Stop(NULL);
ShutDownOnIOThread();
}
« no previous file with comments | « no previous file | content/renderer/media/audio_device_thread.h » ('j') | content/renderer/media/audio_device_thread.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698