Index: content/renderer/media/audio_input_device.h |
=================================================================== |
--- content/renderer/media/audio_input_device.h (revision 94305) |
+++ content/renderer/media/audio_input_device.h (working copy) |
@@ -53,10 +53,9 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/shared_memory.h" |
#include "base/threading/simple_thread.h" |
+#include "base/threading/thread.h" |
#include "content/renderer/media/audio_input_message_filter.h" |
-struct AudioParameters; |
- |
// TODO(henrika): This class is based on the AudioDevice class and it has |
// many components in common. Investigate potential for re-factoring. |
class AudioInputDevice |
@@ -105,16 +104,17 @@ |
virtual void OnVolume(double volume); |
private: |
- // Methods called on IO thread ---------------------------------------------- |
- // The following methods are tasks posted on the IO thread that needs to |
- // be executed on that thread. They interact with AudioInputMessageFilter and |
- // sends IPC messages on that thread. |
- void InitializeOnIOThread(const AudioParameters& params); |
- void StartOnIOThread(); |
- void ShutDownOnIOThread(); |
- void SetVolumeOnIOThread(double volume); |
+ // Methods called on main working thread for AudioInputDevice---------------- |
+ // The following methods are tasks posted on capture_thread_ that needs to |
henrika_dont_use
2011/08/02 09:31:57
Don't think we should use the exact name here. Ple
|
+ // be executed on that thread. |
+ void StartOnCaptureThread(); |
+ void StartRecordingOnCaptureThread(base::SharedMemoryHandle handle, |
+ base::SyncSocket::Handle socket_handle, |
+ uint32 length); |
+ void ShutDownOnCaptureThread(); |
+ void SetVolumeOnCaptureThread(double volume); |
- void Send(IPC::Message* message); |
+ void SendOnIOThread(IPC::Message* message); |
henrika_dont_use
2011/08/02 09:31:57
Move to other IO-methods.
|
// Method called on the audio thread ---------------------------------------- |
// Calls the client's callback for capturing audio. |
@@ -123,6 +123,10 @@ |
// DelegateSimpleThread::Delegate implementation. |
virtual void Run(); |
+ // Add/Remove delegate on IO thread------------------------------------------ |
+ void AddDelegateOnIOThread(); |
+ void RemoveDelegateOnIOThread(int32 stream_id); |
+ |
// Format |
size_t buffer_size_; // in sample-frames |
int channels_; |
@@ -142,6 +146,23 @@ |
// The current volume scaling [0.0, 1.0] of the audio stream. |
double volume_; |
+ // The working thread for AudioInputDevice. |
+ base::Thread capture_thread_; |
+ scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_; |
+ |
+ // These two WaitableEvents are added to translate async Stop (between |
+ // AudioInputDevice and AudioInputMessageFilter) to sync Stop (between |
+ // AudioInputDevice and client). The main reason is that the client can delete |
+ // AudioInputDevice anytime after Stop() is called. To remove this |
+ // translation, it's highly recommended to use async API between client and |
+ // AudioInputDevice. |
+ // WaitableEvent used to synchronize delegate operation since delegate |
+ // needs to be added/removed on IO thread. |
+ base::WaitableEvent delegate_event_; |
+ // WaitableEvent used to synchronize Stop() function call to ensure it's safe |
+ // to destruct AudioInputDevice. |
+ base::WaitableEvent stop_event_; |
+ |
// Callbacks for capturing audio occur on this thread. |
scoped_ptr<base::DelegateSimpleThread> audio_thread_; |