| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Audio rendering unit utilizing audio output stream provided by browser | 5 // Audio rendering unit utilizing audio output stream provided by browser |
| 6 // process through IPC. | 6 // process through IPC. |
| 7 // | 7 // |
| 8 // Relationship of classes. | 8 // Relationship of classes. |
| 9 // | 9 // |
| 10 // AudioRendererHost AudioRendererImpl | 10 // AudioRendererHost AudioRendererImpl |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 public AudioMessageFilter::Delegate, | 58 public AudioMessageFilter::Delegate, |
| 59 public base::DelegateSimpleThread::Delegate, | 59 public base::DelegateSimpleThread::Delegate, |
| 60 public MessageLoop::DestructionObserver { | 60 public MessageLoop::DestructionObserver { |
| 61 public: | 61 public: |
| 62 // Methods called on Render thread ------------------------------------------ | 62 // Methods called on Render thread ------------------------------------------ |
| 63 AudioRendererImpl(); | 63 AudioRendererImpl(); |
| 64 virtual ~AudioRendererImpl(); | 64 virtual ~AudioRendererImpl(); |
| 65 | 65 |
| 66 // Methods called on IO thread ---------------------------------------------- | 66 // Methods called on IO thread ---------------------------------------------- |
| 67 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. | 67 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. |
| 68 virtual void OnRequestPacket(AudioBuffersState buffers_state); | 68 virtual void OnRequestPacket(AudioBuffersState buffers_state) OVERRIDE; |
| 69 virtual void OnStateChanged(AudioStreamState state); | 69 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
| 70 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length); | 70 virtual void OnCreated(base::SharedMemoryHandle handle, |
| 71 uint32 length) OVERRIDE; |
| 71 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 72 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
| 72 base::SyncSocket::Handle socket_handle, | 73 base::SyncSocket::Handle socket_handle, |
| 73 uint32 length); | 74 uint32 length) OVERRIDE; |
| 74 virtual void OnVolume(double volume); | 75 virtual void OnVolume(double volume) OVERRIDE; |
| 75 | 76 |
| 76 // Methods called on pipeline thread ---------------------------------------- | 77 // Methods called on pipeline thread ---------------------------------------- |
| 77 // media::Filter implementation. | 78 // media::Filter implementation. |
| 78 virtual void SetPlaybackRate(float rate); | 79 virtual void SetPlaybackRate(float rate) OVERRIDE; |
| 79 virtual void Pause(const base::Closure& callback); | 80 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 80 virtual void Seek(base::TimeDelta time, const media::FilterStatusCB& cb); | 81 virtual void Seek(base::TimeDelta time, |
| 81 virtual void Play(const base::Closure& callback); | 82 const media::FilterStatusCB& cb) OVERRIDE; |
| 83 virtual void Play(const base::Closure& callback) OVERRIDE; |
| 82 | 84 |
| 83 // media::AudioRenderer implementation. | 85 // media::AudioRenderer implementation. |
| 84 virtual void SetVolume(float volume); | 86 virtual void SetVolume(float volume) OVERRIDE; |
| 85 | 87 |
| 86 protected: | 88 protected: |
| 87 // Methods called on audio renderer thread ---------------------------------- | 89 // Methods called on audio renderer thread ---------------------------------- |
| 88 // These methods are called from AudioRendererBase. | 90 // These methods are called from AudioRendererBase. |
| 89 virtual bool OnInitialize(int bits_per_channel, | 91 virtual bool OnInitialize(int bits_per_channel, |
| 90 ChannelLayout channel_layout, | 92 ChannelLayout channel_layout, |
| 91 int sample_rate); | 93 int sample_rate) OVERRIDE; |
| 92 virtual void OnStop(); | 94 virtual void OnStop() OVERRIDE; |
| 93 | 95 |
| 94 // Called when the decoder completes a Read(). | 96 // Called when the decoder completes a Read(). |
| 95 virtual void ConsumeAudioSamples(scoped_refptr<media::Buffer> buffer_in); | 97 virtual void ConsumeAudioSamples( |
| 98 scoped_refptr<media::Buffer> buffer_in) OVERRIDE; |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 // We are using either low- or high-latency code path. | 101 // We are using either low- or high-latency code path. |
| 99 enum LatencyType { | 102 enum LatencyType { |
| 100 kUninitializedLatency = 0, | 103 kUninitializedLatency = 0, |
| 101 kLowLatency, | 104 kLowLatency, |
| 102 kHighLatency | 105 kHighLatency |
| 103 }; | 106 }; |
| 104 static LatencyType latency_type_; | 107 static LatencyType latency_type_; |
| 105 | 108 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 121 // sends IPC messages on that thread. | 124 // sends IPC messages on that thread. |
| 122 void CreateStreamTask(const AudioParameters& params); | 125 void CreateStreamTask(const AudioParameters& params); |
| 123 void PlayTask(); | 126 void PlayTask(); |
| 124 void PauseTask(); | 127 void PauseTask(); |
| 125 void SeekTask(); | 128 void SeekTask(); |
| 126 void SetVolumeTask(double volume); | 129 void SetVolumeTask(double volume); |
| 127 void NotifyPacketReadyTask(); | 130 void NotifyPacketReadyTask(); |
| 128 void DestroyTask(); | 131 void DestroyTask(); |
| 129 | 132 |
| 130 // Called on IO thread when message loop is dying. | 133 // Called on IO thread when message loop is dying. |
| 131 virtual void WillDestroyCurrentMessageLoop(); | 134 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
| 132 | 135 |
| 133 // DelegateSimpleThread::Delegate implementation. | 136 // DelegateSimpleThread::Delegate implementation. |
| 134 virtual void Run(); | 137 virtual void Run() OVERRIDE; |
| 135 | 138 |
| 136 // (Re-)starts playback. | 139 // (Re-)starts playback. |
| 137 void NotifyDataAvailableIfNecessary(); | 140 void NotifyDataAvailableIfNecessary(); |
| 138 | 141 |
| 139 // Creates socket. Virtual so tests can override. | 142 // Creates socket. Virtual so tests can override. |
| 140 virtual void CreateSocket(base::SyncSocket::Handle socket_handle); | 143 virtual void CreateSocket(base::SyncSocket::Handle socket_handle); |
| 141 | 144 |
| 142 // Launching audio thread. Virtual so tests can override. | 145 // Launching audio thread. Virtual so tests can override. |
| 143 virtual void CreateAudioThread(); | 146 virtual void CreateAudioThread(); |
| 144 | 147 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // remember when it should stop playing, and do not assume that buffer is | 223 // remember when it should stop playing, and do not assume that buffer is |
| 221 // empty till that time. Workaround is not bulletproof, as we don't exactly | 224 // empty till that time. Workaround is not bulletproof, as we don't exactly |
| 222 // know when that particular data would start playing, but it is much better | 225 // know when that particular data would start playing, but it is much better |
| 223 // than nothing. | 226 // than nothing. |
| 224 base::Time earliest_end_time_; | 227 base::Time earliest_end_time_; |
| 225 | 228 |
| 226 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 229 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 227 }; | 230 }; |
| 228 | 231 |
| 229 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_ | 232 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |