| 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 AudioInputController | 38 class MEDIA_EXPORT 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 #if defined(UNIT_TEST) | 102 static void set_factory_for_testing(Factory* factory) { factory_ = factory; } |
| 103 static void set_factory(Factory* factory) { factory_ = factory; } | 103 AudioInputStream* stream_for_testing() { return stream_; } |
| 104 AudioInputStream* stream() { return stream_; } | |
| 105 #endif | |
| 106 | 104 |
| 107 // Starts recording in this audio input stream. | 105 // Starts recording in this audio input stream. |
| 108 virtual void Record(); | 106 virtual void Record(); |
| 109 | 107 |
| 110 // Closes the audio input stream and shutdown the audio input controller | 108 // Closes the audio input stream and shutdown the audio input controller |
| 111 // thread. This method returns only after all operations are completed. This | 109 // thread. This method returns only after all operations are completed. This |
| 112 // input controller cannot be used after this method is called. | 110 // input controller cannot be used after this method is called. |
| 113 // | 111 // |
| 114 // It is safe to call this method more than once. Calls after the first one | 112 // It is safe to call this method more than once. Calls after the first one |
| 115 // will have no effect. | 113 // will have no effect. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 SyncWriter* sync_writer_; | 164 SyncWriter* sync_writer_; |
| 167 | 165 |
| 168 static Factory* factory_; | 166 static Factory* factory_; |
| 169 | 167 |
| 170 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 168 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
| 171 }; | 169 }; |
| 172 | 170 |
| 173 } // namespace media | 171 } // namespace media |
| 174 | 172 |
| 175 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 173 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
| OLD | NEW |