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

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: 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_thread.h
diff --git a/content/renderer/media/audio_device_thread.h b/content/renderer/media/audio_device_thread.h
index aaff1599620386b00258765979ba9dedd93a1544..299e501c815fbf8356f5042f8728a16750a4e881 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() const;
+
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;
+ mutable base::Lock thread_lock_;
scherkus (not reviewing) 2012/02/29 21:10:15 nit: mutable = sadface when would an ADT be const
tommi (sloooow) - chröme 2012/02/29 21:22:13 why? I always figured it would be fair game for sy
scherkus (not reviewing) 2012/02/29 21:40:53 ah it was sadface for the reasons I mentioned (obj
scoped_refptr<AudioDeviceThread::Thread> thread_;
DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread);

Powered by Google App Engine
This is Rietveld 408576698