| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void InitializeOnIOThread(const AudioParameters& params); | 120 void InitializeOnIOThread(const AudioParameters& params); |
| 121 void StartOnIOThread(); | 121 void StartOnIOThread(); |
| 122 void ShutDownOnIOThread(base::WaitableEvent* completion); | 122 void ShutDownOnIOThread(base::WaitableEvent* completion); |
| 123 void SetVolumeOnIOThread(double volume); | 123 void SetVolumeOnIOThread(double volume); |
| 124 | 124 |
| 125 void Send(IPC::Message* message); | 125 void Send(IPC::Message* message); |
| 126 | 126 |
| 127 // Method called on the audio thread (+ one call on the IO thread) ---------- | 127 // Method called on the audio thread (+ one call on the IO thread) ---------- |
| 128 // Calls the client's callback for rendering audio. There will also be one | 128 // Calls the client's callback for rendering audio. There will also be one |
| 129 // initial call on the IO thread before the audio thread has been created. | 129 // initial call on the IO thread before the audio thread has been created. |
| 130 void FireRenderCallback(); | 130 void FireRenderCallback(int16* data); |
| 131 | 131 |
| 132 // DelegateSimpleThread::Delegate implementation. | 132 // DelegateSimpleThread::Delegate implementation. |
| 133 virtual void Run() OVERRIDE; | 133 virtual void Run() OVERRIDE; |
| 134 | 134 |
| 135 // Format | 135 // Format |
| 136 size_t buffer_size_; // in sample-frames | 136 size_t buffer_size_; // in sample-frames |
| 137 int channels_; | 137 int channels_; |
| 138 int bits_per_sample_; | 138 int bits_per_sample_; |
| 139 double sample_rate_; | 139 double sample_rate_; |
| 140 | 140 |
| 141 RenderCallback* callback_; | 141 RenderCallback* callback_; |
| 142 | 142 |
| 143 // The client callback renders audio into here. | 143 // The client callback renders audio into here. |
| 144 std::vector<float*> audio_data_; | 144 std::vector<float*> audio_data_; |
| 145 | 145 |
| 146 // The client stores the last reported audio delay in this member. | 146 // The client stores the last reported audio delay in this member. |
| 147 // The delay shall reflect the amount of audio which still resides in | 147 // The delay shall reflect the amount of audio which still resides in |
| 148 // the output buffer, i.e., the expected audio output delay. | 148 // the output buffer, i.e., the expected audio output delay. |
| 149 int audio_delay_milliseconds_; | 149 int audio_delay_milliseconds_; |
| 150 | 150 |
| 151 // The current volume scaling [0.0, 1.0] of the audio stream. | 151 // The current volume scaling [0.0, 1.0] of the audio stream. |
| 152 double volume_; | 152 double volume_; |
| 153 | 153 |
| 154 // Callbacks for rendering audio occur on this thread. | 154 // Callbacks for rendering audio occur on this thread. |
| 155 scoped_ptr<base::DelegateSimpleThread> audio_thread_; | 155 scoped_ptr<base::DelegateSimpleThread> audio_thread_; |
| 156 | 156 |
| 157 // IPC message stuff. | |
| 158 base::SharedMemory* shared_memory() { return shared_memory_.get(); } | |
| 159 base::SyncSocket* socket() { return socket_.get(); } | |
| 160 void* shared_memory_data() { return shared_memory()->memory(); } | |
| 161 | |
| 162 // Cached audio message filter (lives on the main render thread). | 157 // Cached audio message filter (lives on the main render thread). |
| 163 scoped_refptr<AudioMessageFilter> filter_; | 158 scoped_refptr<AudioMessageFilter> filter_; |
| 164 | 159 |
| 165 // Our stream ID on the message filter. Only accessed on the IO thread. | 160 // Our stream ID on the message filter. Only accessed on the IO thread. |
| 166 int32 stream_id_; | 161 int32 stream_id_; |
| 167 | 162 |
| 168 // Data transfer between browser and render process uses a combination | 163 // Data transfer between browser and render process uses a combination |
| 169 // of sync sockets and shared memory to provide lowest possible latency. | 164 // of sync sockets and shared memory to provide lowest possible latency. |
| 170 scoped_ptr<base::SharedMemory> shared_memory_; | 165 base::SharedMemoryHandle shared_memory_handle_; |
| 171 scoped_ptr<base::SyncSocket> socket_; | 166 base::SyncSocket::Handle socket_handle_; |
| 167 int memory_length_; |
| 172 | 168 |
| 173 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); | 169 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDevice); |
| 174 }; | 170 }; |
| 175 | 171 |
| 176 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ | 172 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ |
| OLD | NEW |