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

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: Remove mutable. Stop thread synchronously if needed in ShutdownOnIOThread with IO exception. 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
« no previous file with comments | « no previous file | content/renderer/media/audio_device_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d4e344a7b3bb0aeaa237c5df2e10dbbe0943b3c7 100644
--- a/content/renderer/media/audio_device.cc
+++ b/content/renderer/media/audio_device.cc
@@ -178,6 +178,15 @@ 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.
+ // Another situation is when the IO thread goes away before Stop() is called
+ // in which case, we cannot use the message loop to close the thread handle
+ // and can't not rely on the main thread existing either.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ audio_thread_.Stop(NULL);
audio_callback_.reset();
}
@@ -218,6 +227,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 +244,7 @@ void AudioDevice::Send(IPC::Message* message) {
}
void AudioDevice::WillDestroyCurrentMessageLoop() {
+ LOG(ERROR) << "IO loop going away before the audio device has been stopped";
ShutDownOnIOThread();
}
« no previous file with comments | « no previous file | content/renderer/media/audio_device_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698