| 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 // Low-latency audio rendering unit utilizing audio output stream provided | 5 // Low-latency audio rendering unit utilizing audio output stream provided |
| 6 // by browser process through IPC. | 6 // by browser process through IPC. |
| 7 // | 7 // |
| 8 // Relationship of classes. | 8 // Relationship of classes. |
| 9 // | 9 // |
| 10 // AudioOutputController AudioDevice | 10 // AudioOutputController AudioDevice |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void GetVolume(double* volume); | 99 void GetVolume(double* volume); |
| 100 | 100 |
| 101 double sample_rate() const { return sample_rate_; } | 101 double sample_rate() const { return sample_rate_; } |
| 102 size_t buffer_size() const { return buffer_size_; } | 102 size_t buffer_size() const { return buffer_size_; } |
| 103 | 103 |
| 104 static double GetAudioHardwareSampleRate(); | 104 static double GetAudioHardwareSampleRate(); |
| 105 static size_t GetAudioHardwareBufferSize(); | 105 static size_t GetAudioHardwareBufferSize(); |
| 106 | 106 |
| 107 // Methods called on IO thread ---------------------------------------------- | 107 // Methods called on IO thread ---------------------------------------------- |
| 108 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. | 108 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. |
| 109 virtual void OnRequestPacket(AudioBuffersState buffers_state); | 109 virtual void OnRequestPacket(AudioBuffersState buffers_state) OVERRIDE; |
| 110 virtual void OnStateChanged(AudioStreamState state); | 110 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
| 111 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length); | 111 virtual void OnCreated(base::SharedMemoryHandle handle, |
| 112 uint32 length) OVERRIDE; |
| 112 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 113 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
| 113 base::SyncSocket::Handle socket_handle, | 114 base::SyncSocket::Handle socket_handle, |
| 114 uint32 length); | 115 uint32 length) OVERRIDE; |
| 115 virtual void OnVolume(double volume); | 116 virtual void OnVolume(double volume) OVERRIDE; |
| 116 | 117 |
| 117 private: | 118 private: |
| 118 // Methods called on IO thread ---------------------------------------------- | 119 // Methods called on IO thread ---------------------------------------------- |
| 119 // The following methods are tasks posted on the IO thread that needs to | 120 // The following methods are tasks posted on the IO thread that needs to |
| 120 // be executed on that thread. They interact with AudioMessageFilter and | 121 // be executed on that thread. They interact with AudioMessageFilter and |
| 121 // sends IPC messages on that thread. | 122 // sends IPC messages on that thread. |
| 122 void InitializeOnIOThread(const AudioParameters& params); | 123 void InitializeOnIOThread(const AudioParameters& params); |
| 123 void StartOnIOThread(); | 124 void StartOnIOThread(); |
| 124 void ShutDownOnIOThread(base::WaitableEvent* completion); | 125 void ShutDownOnIOThread(base::WaitableEvent* completion); |
| 125 void SetVolumeOnIOThread(double volume); | 126 void SetVolumeOnIOThread(double volume); |
| 126 | 127 |
| 127 void Send(IPC::Message* message); | 128 void Send(IPC::Message* message); |
| 128 | 129 |
| 129 // Method called on the audio thread (+ one call on the IO thread) ---------- | 130 // Method called on the audio thread (+ one call on the IO thread) ---------- |
| 130 // Calls the client's callback for rendering audio. There will also be one | 131 // Calls the client's callback for rendering audio. There will also be one |
| 131 // initial call on the IO thread before the audio thread has been created. | 132 // initial call on the IO thread before the audio thread has been created. |
| 132 void FireRenderCallback(); | 133 void FireRenderCallback(); |
| 133 | 134 |
| 134 // DelegateSimpleThread::Delegate implementation. | 135 // DelegateSimpleThread::Delegate implementation. |
| 135 virtual void Run(); | 136 virtual void Run() OVERRIDE; |
| 136 | 137 |
| 137 // Format | 138 // Format |
| 138 size_t buffer_size_; // in sample-frames | 139 size_t buffer_size_; // in sample-frames |
| 139 int channels_; | 140 int channels_; |
| 140 int bits_per_sample_; | 141 int bits_per_sample_; |
| 141 double sample_rate_; | 142 double sample_rate_; |
| 142 | 143 |
| 143 RenderCallback* callback_; | 144 RenderCallback* callback_; |
| 144 | 145 |
| 145 // The client callback renders audio into here. | 146 // The client callback renders audio into here. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 169 | 170 |
| 170 // Data transfer between browser and render process uses a combination | 171 // Data transfer between browser and render process uses a combination |
| 171 // of sync sockets and shared memory to provide lowest possible latency. | 172 // of sync sockets and shared memory to provide lowest possible latency. |
| 172 scoped_ptr<base::SharedMemory> shared_memory_; | 173 scoped_ptr<base::SharedMemory> shared_memory_; |
| 173 scoped_ptr<base::SyncSocket> socket_; | 174 scoped_ptr<base::SyncSocket> socket_; |
| 174 | 175 |
| 175 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); | 176 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); |
| 176 }; | 177 }; |
| 177 | 178 |
| 178 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ | 179 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ |
| OLD | NEW |