Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 EventHandler* event_handler, | 93 EventHandler* event_handler, |
| 94 AudioParameters params, | 94 AudioParameters params, |
| 95 // External synchronous reader for audio controller. | 95 // External synchronous reader for audio controller. |
| 96 SyncWriter* sync_writer); | 96 SyncWriter* sync_writer); |
| 97 | 97 |
| 98 // Sets the factory used by the static method Create. AudioInputController | 98 // Sets the factory used by the static method Create. AudioInputController |
| 99 // does not take ownership of |factory|. A value of NULL results in an | 99 // does not take ownership of |factory|. A value of NULL results in an |
| 100 // AudioInputController being created directly. | 100 // AudioInputController being created directly. |
| 101 #if defined(UNIT_TEST) | 101 #if defined(UNIT_TEST) |
| 102 static void set_factory(Factory* factory) { factory_ = factory; } | 102 static void set_factory(Factory* factory) { factory_ = factory; } |
| 103 AudioInputStream* getAudioInputStream() { return stream_; } | |
|
scherkus (not reviewing)
2011/06/13 19:04:56
nit: should be stream()
allanwoj
2011/06/14 15:03:12
Done.
| |
| 103 #endif | 104 #endif |
| 104 | 105 |
| 105 // Starts recording in this audio input stream. | 106 // Starts recording in this audio input stream. |
| 106 virtual void Record(); | 107 virtual void Record(); |
| 107 | 108 |
| 108 // Closes the audio input stream and shutdown the audio input controller | 109 // Closes the audio input stream and shutdown the audio input controller |
| 109 // thread. This method returns only after all operations are completed. This | 110 // thread. This method returns only after all operations are completed. This |
| 110 // input controller cannot be used after this method is called. | 111 // input controller cannot be used after this method is called. |
| 111 // | 112 // |
| 112 // It is safe to call this method more than once. Calls after the first one | 113 // It is safe to call this method more than once. Calls after the first one |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 131 kError | 132 kError |
| 132 }; | 133 }; |
| 133 | 134 |
| 134 AudioInputController(EventHandler* handler, SyncWriter* sync_writer); | 135 AudioInputController(EventHandler* handler, SyncWriter* sync_writer); |
| 135 | 136 |
| 136 // The following methods are executed on the audio controller thread. | 137 // The following methods are executed on the audio controller thread. |
| 137 void DoCreate(AudioParameters params); | 138 void DoCreate(AudioParameters params); |
| 138 void DoRecord(); | 139 void DoRecord(); |
| 139 void DoClose(); | 140 void DoClose(); |
| 140 void DoReportError(int code); | 141 void DoReportError(int code); |
| 142 void DoDataCountCheck(); | |
| 143 | |
| 144 void ScheduleDataCountCheck(); | |
| 141 | 145 |
| 142 EventHandler* handler_; | 146 EventHandler* handler_; |
| 143 AudioInputStream* stream_; | 147 AudioInputStream* stream_; |
| 144 | 148 |
| 149 // Incremented on each call to OnData. | |
| 150 int on_data_call_count_; | |
| 151 // Only used on the audio controller thread. | |
| 152 int previous_on_data_count_; | |
| 153 | |
| 145 // |state_| is written on the audio input controller thread and is read on | 154 // |state_| is written on the audio input controller thread and is read on |
| 146 // the hardware audio thread. These operations need to be locked. But lock | 155 // the hardware audio thread. These operations need to be locked. But lock |
| 147 // is not required for reading on the audio input controller thread. | 156 // is not required for reading on the audio input controller thread. |
| 148 State state_; | 157 State state_; |
| 149 | 158 |
| 150 base::Lock lock_; | 159 base::Lock lock_; |
| 151 | 160 |
| 152 // The audio input controller thread that this object runs on. | 161 // The audio input controller thread that this object runs on. |
| 153 base::Thread thread_; | 162 base::Thread thread_; |
| 154 | 163 |
| 155 // SyncWriter is used only in low latency mode for synchronous writing. | 164 // SyncWriter is used only in low latency mode for synchronous writing. |
| 156 SyncWriter* sync_writer_; | 165 SyncWriter* sync_writer_; |
| 157 | 166 |
| 158 static Factory* factory_; | 167 static Factory* factory_; |
| 159 | 168 |
| 160 DISALLOW_COPY_AND_ASSIGN(AudioInputController); | 169 DISALLOW_COPY_AND_ASSIGN(AudioInputController); |
| 161 }; | 170 }; |
| 162 | 171 |
| 163 } // namespace media | 172 } // namespace media |
| 164 | 173 |
| 165 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ | 174 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ |
| OLD | NEW |