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 #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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // | | | 28 // | | |
29 // [ Created ] ----------> [ Recording ] | 29 // [ Created ] ----------> [ Recording ] |
30 // ^ | 30 // ^ |
31 // | | 31 // | |
32 // *[ Empty ] | 32 // *[ Empty ] |
33 // | 33 // |
34 // * Initial state | 34 // * Initial state |
35 // | 35 // |
36 namespace media { | 36 namespace media { |
37 | 37 |
38 class MEDIA_EXPORT AudioInputController | 38 class AudioInputController |
39 : public base::RefCountedThreadSafe<AudioInputController>, | 39 : public base::RefCountedThreadSafe<AudioInputController>, |
40 public AudioInputStream::AudioInputCallback { | 40 public AudioInputStream::AudioInputCallback { |
41 public: | 41 public: |
42 // An event handler that receives events from the AudioInputController. The | 42 // An event handler that receives events from the AudioInputController. The |
43 // following methods are called on the audio input controller thread. | 43 // following methods are called on the audio input controller thread. |
44 class EventHandler { | 44 class EventHandler { |
45 public: | 45 public: |
46 virtual ~EventHandler() {} | 46 virtual ~EventHandler() {} |
47 virtual void OnCreated(AudioInputController* controller) = 0; | 47 virtual void OnCreated(AudioInputController* controller) = 0; |
48 virtual void OnRecording(AudioInputController* controller) = 0; | 48 virtual void OnRecording(AudioInputController* controller) = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Factory method for creating a low latency audio stream. | 92 // Factory method for creating a low latency audio stream. |
93 static scoped_refptr<AudioInputController> CreateLowLatency( | 93 static scoped_refptr<AudioInputController> CreateLowLatency( |
94 EventHandler* event_handler, | 94 EventHandler* event_handler, |
95 const AudioParameters& params, | 95 const AudioParameters& params, |
96 // External synchronous reader for audio controller. | 96 // External synchronous reader for audio controller. |
97 SyncWriter* sync_writer); | 97 SyncWriter* sync_writer); |
98 | 98 |
99 // Sets the factory used by the static method Create. AudioInputController | 99 // Sets the factory used by the static method Create. AudioInputController |
100 // does not take ownership of |factory|. A value of NULL results in an | 100 // does not take ownership of |factory|. A value of NULL results in an |
101 // AudioInputController being created directly. | 101 // AudioInputController being created directly. |
102 static void set_factory_for_testing(Factory* factory) { factory_ = factory; } | 102 #if defined(UNIT_TEST) |
103 AudioInputStream* stream_for_testing() { return stream_; } | 103 static void set_factory(Factory* factory) { factory_ = factory; } |
| 104 AudioInputStream* stream() { return stream_; } |
| 105 #endif |
104 | 106 |
105 // Starts recording in this audio input stream. | 107 // Starts recording in this audio input stream. |
106 virtual void Record(); | 108 virtual void Record(); |
107 | 109 |
108 // Closes the audio input stream and shutdown the audio input controller | 110 // Closes the audio input stream and shutdown the audio input controller |
109 // thread. This method returns only after all operations are completed. This | 111 // thread. This method returns only after all operations are completed. This |
110 // input controller cannot be used after this method is called. | 112 // input controller cannot be used after this method is called. |
111 // | 113 // |
112 // It is safe to call this method more than once. Calls after the first one | 114 // It is safe to call this method more than once. Calls after the first one |
113 // will have no effect. | 115 // will have no effect. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 SyncWriter* sync_writer_; | 166 SyncWriter* sync_writer_; |
165 | 167 |
166 static Factory* factory_; | 168 static Factory* factory_; |
167 | 169 |
168 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 170 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
169 }; | 171 }; |
170 | 172 |
171 } // namespace media | 173 } // namespace media |
172 | 174 |
173 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 175 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
OLD | NEW |