| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 virtual void OnDeviceStopped() = 0; | 114 virtual void OnDeviceStopped() = 0; |
| 115 | 115 |
| 116 protected: | 116 protected: |
| 117 virtual ~CaptureEventHandler() {} | 117 virtual ~CaptureEventHandler() {} |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 // Methods called on main render thread ------------------------------------- | 120 // Methods called on main render thread ------------------------------------- |
| 121 AudioInputDevice(const media::AudioParameters& params, | 121 AudioInputDevice(const media::AudioParameters& params, |
| 122 CaptureCallback* callback, | 122 CaptureCallback* callback, |
| 123 CaptureEventHandler* event_handler); | 123 CaptureEventHandler* event_handler); |
| 124 virtual ~AudioInputDevice(); | |
| 125 | 124 |
| 126 // Specify the |session_id| to query which device to use. This method is | 125 // Specify the |session_id| to query which device to use. This method is |
| 127 // asynchronous/non-blocking. | 126 // asynchronous/non-blocking. |
| 128 // Start() will use the second sequence if this method is called before. | 127 // Start() will use the second sequence if this method is called before. |
| 129 void SetDevice(int session_id); | 128 void SetDevice(int session_id); |
| 130 | 129 |
| 131 // Starts audio capturing. This method is asynchronous/non-blocking. | 130 // Starts audio capturing. This method is asynchronous/non-blocking. |
| 132 // TODO(henrika): add support for notification when recording has started. | 131 // TODO(henrika): add support for notification when recording has started. |
| 133 void Start(); | 132 void Start(); |
| 134 | 133 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 160 // Methods called on IO thread ---------------------------------------------- | 159 // Methods called on IO thread ---------------------------------------------- |
| 161 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter. | 160 // AudioInputMessageFilter::Delegate impl., called by AudioInputMessageFilter. |
| 162 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 161 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 163 base::SyncSocket::Handle socket_handle, | 162 base::SyncSocket::Handle socket_handle, |
| 164 uint32 length) OVERRIDE; | 163 uint32 length) OVERRIDE; |
| 165 virtual void OnVolume(double volume) OVERRIDE; | 164 virtual void OnVolume(double volume) OVERRIDE; |
| 166 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; | 165 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
| 167 virtual void OnDeviceReady(const std::string& device_id) OVERRIDE; | 166 virtual void OnDeviceReady(const std::string& device_id) OVERRIDE; |
| 168 | 167 |
| 169 private: | 168 private: |
| 169 friend class base::RefCountedThreadSafe<AudioInputDevice>; |
| 170 virtual ~AudioInputDevice(); |
| 171 |
| 170 // Methods called on IO thread ---------------------------------------------- | 172 // Methods called on IO thread ---------------------------------------------- |
| 171 // The following methods are tasks posted on the IO thread that needs to | 173 // The following methods are tasks posted on the IO thread that needs to |
| 172 // be executed on that thread. They interact with AudioInputMessageFilter and | 174 // be executed on that thread. They interact with AudioInputMessageFilter and |
| 173 // sends IPC messages on that thread. | 175 // sends IPC messages on that thread. |
| 174 void InitializeOnIOThread(); | 176 void InitializeOnIOThread(); |
| 175 void SetSessionIdOnIOThread(int session_id); | 177 void SetSessionIdOnIOThread(int session_id); |
| 176 void StartOnIOThread(); | 178 void StartOnIOThread(); |
| 177 void ShutDownOnIOThread(); | 179 void ShutDownOnIOThread(); |
| 178 void SetVolumeOnIOThread(double volume); | 180 void SetVolumeOnIOThread(double volume); |
| 179 void SetAutomaticGainControlOnIOThread(bool enabled); | 181 void SetAutomaticGainControlOnIOThread(bool enabled); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // In order to avoid a race between OnStreamCreated and Stop(), we use this | 219 // In order to avoid a race between OnStreamCreated and Stop(), we use this |
| 218 // guard to control stopping and starting the audio thread. | 220 // guard to control stopping and starting the audio thread. |
| 219 base::Lock audio_thread_lock_; | 221 base::Lock audio_thread_lock_; |
| 220 AudioDeviceThread audio_thread_; | 222 AudioDeviceThread audio_thread_; |
| 221 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; | 223 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; |
| 222 | 224 |
| 223 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 225 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
| 224 }; | 226 }; |
| 225 | 227 |
| 226 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 228 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
| OLD | NEW |