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

Unified Diff: content/renderer/media/audio_input_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_input_device.cc
diff --git a/content/renderer/media/audio_input_device.cc b/content/renderer/media/audio_input_device.cc
index 95ade0831460deeb4fd6ebe49177d50b8e7edf83..88c9b1f8af27db8d9020385ab74b02890a2e25a6 100644
--- a/content/renderer/media/audio_input_device.cc
+++ b/content/renderer/media/audio_input_device.cc
@@ -146,6 +146,12 @@ void AudioInputDevice::ShutDownOnIOThread() {
session_id_ = 0;
pending_device_ready_ = false;
}
+
+ // 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());
audio_callback_.reset();
}
@@ -178,11 +184,11 @@ void AudioInputDevice::OnStreamCreated(
return;
}
+ DCHECK(audio_thread_.IsStopped());
audio_callback_.reset(
new AudioInputDevice::AudioThreadCallback(audio_parameters_, handle,
length, callback_));
- audio_thread_.Start(audio_callback_.get(), socket_handle,
- "AudioInputDevice");
+ audio_thread_.Start(audio_callback_.get(), socket_handle, "AudioInputDevice");
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&AudioInputDevice::StartOnIOThread, this));
@@ -258,6 +264,8 @@ void AudioInputDevice::Send(IPC::Message* message) {
}
void AudioInputDevice::WillDestroyCurrentMessageLoop() {
scherkus (not reviewing) 2012/02/29 21:10:15 ditto
+ LOG(ERROR) << "IO loop going away before the input device has been stopped";
+ audio_thread_.Stop(NULL);
ShutDownOnIOThread();
}
« content/renderer/media/audio_device_thread.h ('K') | « content/renderer/media/audio_device_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698