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 #ifndef MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // done, the event handler will receive an OnCreated() call from that same | 139 // done, the event handler will receive an OnCreated() call from that same |
140 // thread. | 140 // thread. |
141 static scoped_refptr<AudioInputController> CreateLowLatency( | 141 static scoped_refptr<AudioInputController> CreateLowLatency( |
142 AudioManager* audio_manager, | 142 AudioManager* audio_manager, |
143 EventHandler* event_handler, | 143 EventHandler* event_handler, |
144 const AudioParameters& params, | 144 const AudioParameters& params, |
145 const std::string& device_id, | 145 const std::string& device_id, |
146 // External synchronous writer for audio controller. | 146 // External synchronous writer for audio controller. |
147 SyncWriter* sync_writer); | 147 SyncWriter* sync_writer); |
148 | 148 |
| 149 // Factory method for creating an AudioInputController for low-latency mode, |
| 150 // taking ownership of |stream|. The stream will be opened on the audio |
| 151 // thread, and when that is done, the event handler will receive an |
| 152 // OnCreated() call from that same thread. |
| 153 static scoped_refptr<AudioInputController> CreateForStream( |
| 154 AudioManager* audio_manager, |
| 155 EventHandler* event_handler, |
| 156 AudioInputStream* stream, |
| 157 // External synchronous writer for audio controller. |
| 158 SyncWriter* sync_writer); |
| 159 |
149 // Starts recording using the created audio input stream. | 160 // Starts recording using the created audio input stream. |
150 // This method is called on the creator thread. | 161 // This method is called on the creator thread. |
151 virtual void Record(); | 162 virtual void Record(); |
152 | 163 |
153 // Closes the audio input stream. The state is changed and the resources | 164 // Closes the audio input stream. The state is changed and the resources |
154 // are freed on the audio thread. |closed_task| is then executed on the thread | 165 // are freed on the audio thread. |closed_task| is then executed on the thread |
155 // that called Close(). | 166 // that called Close(). |
156 // Callbacks (EventHandler and SyncWriter) must exist until |closed_task| | 167 // Callbacks (EventHandler and SyncWriter) must exist until |closed_task| |
157 // is called. | 168 // is called. |
158 // It is safe to call this method more than once. Calls after the first one | 169 // It is safe to call this method more than once. Calls after the first one |
(...skipping 29 matching lines...) Expand all Loading... |
188 kClosed, | 199 kClosed, |
189 kError | 200 kError |
190 }; | 201 }; |
191 | 202 |
192 AudioInputController(EventHandler* handler, SyncWriter* sync_writer); | 203 AudioInputController(EventHandler* handler, SyncWriter* sync_writer); |
193 virtual ~AudioInputController(); | 204 virtual ~AudioInputController(); |
194 | 205 |
195 // Methods called on the audio thread (owned by the AudioManager). | 206 // Methods called on the audio thread (owned by the AudioManager). |
196 void DoCreate(AudioManager* audio_manager, const AudioParameters& params, | 207 void DoCreate(AudioManager* audio_manager, const AudioParameters& params, |
197 const std::string& device_id); | 208 const std::string& device_id); |
| 209 void DoCreateForStream(AudioInputStream* stream_to_control); |
198 void DoRecord(); | 210 void DoRecord(); |
199 void DoClose(); | 211 void DoClose(); |
200 void DoReportError(int code); | 212 void DoReportError(int code); |
201 void DoSetVolume(double volume); | 213 void DoSetVolume(double volume); |
202 void DoSetAutomaticGainControl(bool enabled); | 214 void DoSetAutomaticGainControl(bool enabled); |
203 | 215 |
204 // Method which ensures that OnError() is triggered when data recording | 216 // Method which ensures that OnError() is triggered when data recording |
205 // times out. Called on the audio thread. | 217 // times out. Called on the audio thread. |
206 void DoCheckForNoData(); | 218 void DoCheckForNoData(); |
207 | 219 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 static Factory* factory_; | 263 static Factory* factory_; |
252 | 264 |
253 double max_volume_; | 265 double max_volume_; |
254 | 266 |
255 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 267 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
256 }; | 268 }; |
257 | 269 |
258 } // namespace media | 270 } // namespace media |
259 | 271 |
260 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 272 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
OLD | NEW |