| 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 capturing unit utilizing audio input stream provided | 5 // Low-latency audio capturing unit utilizing audio input 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 // AudioInputController AudioInputDevice | 10 // AudioInputController AudioInputDevice |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Returns |true| on success. | 141 // Returns |true| on success. |
| 142 bool GetVolume(double* volume); | 142 bool GetVolume(double* volume); |
| 143 | 143 |
| 144 double sample_rate() const { return audio_parameters_.sample_rate; } | 144 double sample_rate() const { return audio_parameters_.sample_rate; } |
| 145 size_t buffer_size() const { return audio_parameters_.samples_per_packet; } | 145 size_t buffer_size() const { return audio_parameters_.samples_per_packet; } |
| 146 | 146 |
| 147 // Methods called on IO thread ---------------------------------------------- | 147 // Methods called on IO thread ---------------------------------------------- |
| 148 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter | 148 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter |
| 149 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 149 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
| 150 base::SyncSocket::Handle socket_handle, | 150 base::SyncSocket::Handle socket_handle, |
| 151 uint32 length); | 151 uint32 length) OVERRIDE; |
| 152 virtual void OnVolume(double volume); | 152 virtual void OnVolume(double volume) OVERRIDE; |
| 153 virtual void OnStateChanged(AudioStreamState state); | 153 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
| 154 virtual void OnDeviceReady(int index); | 154 virtual void OnDeviceReady(int index) OVERRIDE; |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 // Methods called on IO thread ---------------------------------------------- | 157 // Methods called on IO thread ---------------------------------------------- |
| 158 // The following methods are tasks posted on the IO thread that needs to | 158 // The following methods are tasks posted on the IO thread that needs to |
| 159 // be executed on that thread. They interact with AudioInputMessageFilter and | 159 // be executed on that thread. They interact with AudioInputMessageFilter and |
| 160 // sends IPC messages on that thread. | 160 // sends IPC messages on that thread. |
| 161 void InitializeOnIOThread(); | 161 void InitializeOnIOThread(); |
| 162 void SetSessionIdOnIOThread(int session_id); | 162 void SetSessionIdOnIOThread(int session_id); |
| 163 void StartOnIOThread(); | 163 void StartOnIOThread(); |
| 164 void ShutDownOnIOThread(base::WaitableEvent* completion); | 164 void ShutDownOnIOThread(base::WaitableEvent* completion); |
| 165 void SetVolumeOnIOThread(double volume); | 165 void SetVolumeOnIOThread(double volume); |
| 166 | 166 |
| 167 void Send(IPC::Message* message); | 167 void Send(IPC::Message* message); |
| 168 | 168 |
| 169 // Method called on the audio thread ---------------------------------------- | 169 // Method called on the audio thread ---------------------------------------- |
| 170 // Calls the client's callback for capturing audio. | 170 // Calls the client's callback for capturing audio. |
| 171 void FireCaptureCallback(); | 171 void FireCaptureCallback(); |
| 172 | 172 |
| 173 // DelegateSimpleThread::Delegate implementation. | 173 // DelegateSimpleThread::Delegate implementation. |
| 174 virtual void Run(); | 174 virtual void Run() OVERRIDE; |
| 175 | 175 |
| 176 // Format | 176 // Format |
| 177 AudioParameters audio_parameters_; | 177 AudioParameters audio_parameters_; |
| 178 | 178 |
| 179 CaptureCallback* callback_; | 179 CaptureCallback* callback_; |
| 180 CaptureEventHandler* event_handler_; | 180 CaptureEventHandler* event_handler_; |
| 181 | 181 |
| 182 // The client callback receives captured audio here. | 182 // The client callback receives captured audio here. |
| 183 std::vector<float*> audio_data_; | 183 std::vector<float*> audio_data_; |
| 184 | 184 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 212 // callback. Only modified on the IO thread. | 212 // callback. Only modified on the IO thread. |
| 213 bool pending_device_ready_; | 213 bool pending_device_ready_; |
| 214 | 214 |
| 215 scoped_ptr<base::SharedMemory> shared_memory_; | 215 scoped_ptr<base::SharedMemory> shared_memory_; |
| 216 scoped_ptr<base::SyncSocket> socket_; | 216 scoped_ptr<base::SyncSocket> socket_; |
| 217 | 217 |
| 218 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 218 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 221 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
| OLD | NEW |