Index: content/renderer/media/audio_renderer_impl.h |
=================================================================== |
--- content/renderer/media/audio_renderer_impl.h (revision 91508) |
+++ content/renderer/media/audio_renderer_impl.h (working copy) |
@@ -43,6 +43,7 @@ |
#include "base/message_loop.h" |
#include "base/shared_memory.h" |
#include "base/synchronization/lock.h" |
+#include "base/threading/simple_thread.h" |
#include "content/renderer/media/audio_message_filter.h" |
#include "media/audio/audio_io.h" |
#include "media/audio/audio_manager.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_; |