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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // to create the AudioInputController. Factory is intended for testing only. | 107 // to create the AudioInputController. Factory is intended for testing only. |
108 class Factory { | 108 class Factory { |
109 public: | 109 public: |
110 virtual AudioInputController* Create(AudioManager* audio_manager, | 110 virtual AudioInputController* Create(AudioManager* audio_manager, |
111 EventHandler* event_handler, | 111 EventHandler* event_handler, |
112 AudioParameters params) = 0; | 112 AudioParameters params) = 0; |
113 protected: | 113 protected: |
114 virtual ~Factory() {} | 114 virtual ~Factory() {} |
115 }; | 115 }; |
116 | 116 |
117 virtual ~AudioInputController(); | |
118 | |
119 // Factory method for creating an AudioInputController. | 117 // Factory method for creating an AudioInputController. |
120 // The audio device will be created on the audio thread, and when that is | 118 // The audio device will be created on the audio thread, and when that is |
121 // done, the event handler will receive an OnCreated() call from that same | 119 // done, the event handler will receive an OnCreated() call from that same |
122 // thread. | 120 // thread. |
123 static scoped_refptr<AudioInputController> Create( | 121 static scoped_refptr<AudioInputController> Create( |
124 AudioManager* audio_manager, | 122 AudioManager* audio_manager, |
125 EventHandler* event_handler, | 123 EventHandler* event_handler, |
126 const AudioParameters& params); | 124 const AudioParameters& params); |
127 | 125 |
128 // Sets the factory used by the static method Create(). AudioInputController | 126 // Sets the factory used by the static method Create(). AudioInputController |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 uint32 hardware_delay_bytes, double volume) OVERRIDE; | 169 uint32 hardware_delay_bytes, double volume) OVERRIDE; |
172 virtual void OnClose(AudioInputStream* stream) OVERRIDE; | 170 virtual void OnClose(AudioInputStream* stream) OVERRIDE; |
173 virtual void OnError(AudioInputStream* stream, int code) OVERRIDE; | 171 virtual void OnError(AudioInputStream* stream, int code) OVERRIDE; |
174 | 172 |
175 bool LowLatencyMode() const { return sync_writer_ != NULL; } | 173 bool LowLatencyMode() const { return sync_writer_ != NULL; } |
176 scoped_refptr<base::MessageLoopProxy> message_loop() const { | 174 scoped_refptr<base::MessageLoopProxy> message_loop() const { |
177 return message_loop_; | 175 return message_loop_; |
178 } | 176 } |
179 | 177 |
180 protected: | 178 protected: |
| 179 friend class base::RefCountedThreadSafe<AudioInputController>; |
| 180 virtual ~AudioInputController(); |
| 181 |
181 // Internal state of the source. | 182 // Internal state of the source. |
182 enum State { | 183 enum State { |
183 kEmpty, | 184 kEmpty, |
184 kCreated, | 185 kCreated, |
185 kRecording, | 186 kRecording, |
186 kClosed, | 187 kClosed, |
187 kError | 188 kError |
188 }; | 189 }; |
189 | 190 |
190 AudioInputController(EventHandler* handler, SyncWriter* sync_writer); | 191 AudioInputController(EventHandler* handler, SyncWriter* sync_writer); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 static Factory* factory_; | 241 static Factory* factory_; |
241 | 242 |
242 double max_volume_; | 243 double max_volume_; |
243 | 244 |
244 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 245 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
245 }; | 246 }; |
246 | 247 |
247 } // namespace media | 248 } // namespace media |
248 | 249 |
249 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 250 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
OLD | NEW |