Chromium Code Reviews| Index: content/renderer/media/audio_renderer_impl.h |
| =================================================================== |
| --- content/renderer/media/audio_renderer_impl.h (revision 90349) |
| +++ content/renderer/media/audio_renderer_impl.h (working copy) |
| @@ -41,6 +41,7 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/message_loop.h" |
| +#include "base/threading/simple_thread.h" |
|
brettw
2011/07/06 22:13:23
This should be in order (moved below 's')
|
| #include "base/shared_memory.h" |
| #include "base/synchronization/lock.h" |
| #include "content/renderer/media/audio_message_filter.h" |
| @@ -53,6 +54,7 @@ |
| class AudioRendererImpl : public media::AudioRendererBase, |
| public AudioMessageFilter::Delegate, |
| + public base::DelegateSimpleThread::Delegate, |
| public MessageLoop::DestructionObserver { |
| public: |
| // Methods called on Render thread ------------------------------------------ |
| @@ -89,6 +91,14 @@ |
| virtual void ConsumeAudioSamples(scoped_refptr<media::Buffer> buffer_in); |
| private: |
| + // We are using either low- or high-latency code path. |
| + enum LatencyType { |
| + kUninitializedLatency = 0, |
| + kLowLatency, |
| + kHighLatency |
| + }; |
| + static LatencyType latency_type_; |
| + |
| // For access to constructor and IO thread methods. |
| friend class AudioRendererImplTest; |
| FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, Stop); |
| @@ -114,6 +124,26 @@ |
| // Called on IO thread when message loop is dying. |
| virtual void WillDestroyCurrentMessageLoop(); |
| + // DelegateSimpleThread::Delegate implementation. |
| + virtual void Run(); |
| + |
| + // (Re-)starts playback. |
| + void NotifyDataAvailableIfNecessary(); |
| + |
| + // Creates socket. Virtual so tests can override. |
| + virtual void CreateSocket(base::SyncSocket::Handle socket_handle); |
| + |
| + // Launching audio thread. Virtual so tests can override. |
| + virtual void CreateAudioThread(); |
| + |
| + // Accessors used by tests. |
| + LatencyType latency_type() { |
| + return latency_type_; |
| + } |
| + |
| + // Should be called before any class instance is created. |
| + static void set_latency_type(LatencyType latency_type); |
| + |
| // Used to calculate audio delay given bytes. |
| uint32 bytes_per_second_; |
| @@ -126,6 +156,12 @@ |
| scoped_ptr<base::SharedMemory> shared_memory_; |
| uint32 shared_memory_size_; |
| + // Low latency IPC stuff. |
| + scoped_ptr<base::SyncSocket> socket_; |
| + |
| + // That thread waits for audio input. |
| + scoped_ptr<base::DelegateSimpleThread> audio_thread_; |
| + |
| // Message loop for the IO thread. |
| MessageLoop* io_loop_; |