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

Unified Diff: content/renderer/media/audio_device_thread.h

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 | « content/renderer/media/audio_device.cc ('k') | content/renderer/media/audio_device_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/audio_device_thread.h
diff --git a/content/renderer/media/audio_device_thread.h b/content/renderer/media/audio_device_thread.h
index aaff1599620386b00258765979ba9dedd93a1544..51c6fdac75e3589af7ea5537c1935adf20c116af 100644
--- a/content/renderer/media/audio_device_thread.h
+++ b/content/renderer/media/audio_device_thread.h
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/shared_memory.h"
#include "base/sync_socket.h"
+#include "base/synchronization/lock.h"
#include "content/common/content_export.h"
#include "media/audio/audio_parameters.h"
@@ -76,16 +77,19 @@ class CONTENT_EXPORT AudioDeviceThread {
const char* thread_name);
// This tells the audio thread to stop and clean up the data.
- // The method is asynchronous, so the thread might still be running after it
+ // The method can stop the thread synchronously or asynchronously.
+ // In the latter case, the thread will still be running after Stop()
// returns, but the callback pointer is cleared so no further callbacks will
- // be made (i.e. after Stop() returns, it is safe to delete the callback).
- // The |loop_for_join| parameter is required in order to join the worker
- // thread and close the thread handle later via a posted task.
- // If set to NULL, the current message loop is used. Note that the thread
- // that the message loop belongs to, must be allowed to join threads
- // (see SetIOAllowed in base/thread_restrictions.h).
+ // be made (IOW after Stop() returns, it is safe to delete the callback).
+ // The |loop_for_join| parameter is required for asynchronous operation
+ // in order to join the worker thread and close the thread handle later via a
+ // posted task.
+ // If set to NULL, function will wait for the thread to exit before returning.
void Stop(MessageLoop* loop_for_join);
+ // Returns true if the thread is stopped or stopping.
+ bool IsStopped();
+
private:
// Our own private SimpleThread override. We implement this in a
// private class so that we get the following benefits:
@@ -96,6 +100,7 @@ class CONTENT_EXPORT AudioDeviceThread {
// reliable initialization.
class Thread;
+ base::Lock thread_lock_;
scoped_refptr<AudioDeviceThread::Thread> thread_;
DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread);
« no previous file with comments | « content/renderer/media/audio_device.cc ('k') | content/renderer/media/audio_device_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698