| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_OUTPUT_CONTROLLER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/thread.h" |
| 11 #include "base/time.h" | 12 #include "base/time.h" |
| 12 #include "media/audio/audio_io.h" | 13 #include "media/audio/audio_io.h" |
| 13 #include "media/audio/audio_manager.h" | |
| 14 #include "media/audio/simple_sources.h" | 14 #include "media/audio/simple_sources.h" |
| 15 | 15 |
| 16 class MessageLoop; | |
| 17 | |
| 18 // An AudioOutputController controls an AudioOutputStream and provides data | 16 // An AudioOutputController controls an AudioOutputStream and provides data |
| 19 // to this output stream. It has an important function that it executes | 17 // to this output stream. It has an important function that it executes |
| 20 // audio operations like play, pause, stop, etc. on a separate thread, | 18 // audio operations like play, pause, stop, etc. on a separate thread, |
| 21 // namely the audio controller thread. | 19 // namely the audio controller thread. |
| 22 // | 20 // |
| 23 // All the public methods of AudioOutputController are non-blocking except | 21 // All the public methods of AudioOutputController are non-blocking except |
| 24 // close, the actual operations are performed on the audio controller thread. | 22 // close, the actual operations are performed on the audio controller thread. |
| 25 // | 23 // |
| 26 // Here is a state diagram for the AudioOutputController: | 24 // Here is a state diagram for the AudioOutputController: |
| 27 // | 25 // |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Starts the playback of this audio output stream. | 131 // Starts the playback of this audio output stream. |
| 134 void Play(); | 132 void Play(); |
| 135 | 133 |
| 136 // Pause this audio output stream. | 134 // Pause this audio output stream. |
| 137 void Pause(); | 135 void Pause(); |
| 138 | 136 |
| 139 // Discard all audio data buffered in this output stream. This method only | 137 // Discard all audio data buffered in this output stream. This method only |
| 140 // has effect when the stream is paused. | 138 // has effect when the stream is paused. |
| 141 void Flush(); | 139 void Flush(); |
| 142 | 140 |
| 143 // Closes the audio output stream. It changes state to kClosed and returns | 141 // Closes the audio output stream and shutdown the audio controller thread. |
| 144 // right away. The physical resources are freed on the audio thread if | 142 // This method returns only after all operations are completed. This |
| 145 // neccessary. | 143 // controller cannot be used after this method is called. |
| 146 // | 144 // |
| 147 // It is safe to call this method more than once. Calls after the first one | 145 // It is safe to call this method more than once. Calls after the first one |
| 148 // will have no effect. | 146 // will have no effect. |
| 149 void Close(); | 147 void Close(); |
| 150 | 148 |
| 151 // Sets the volume of the audio output stream. | 149 // Sets the volume of the audio output stream. |
| 152 void SetVolume(double volume); | 150 void SetVolume(double volume); |
| 153 | 151 |
| 154 // Enqueue audio |data| into the controller. This method is used only in | 152 // Enqueue audio |data| into the controller. This method is used only in |
| 155 // the regular latency mode and it is illegal to call this method when | 153 // the regular latency mode and it is illegal to call this method when |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 base::Time last_callback_time_; | 196 base::Time last_callback_time_; |
| 199 Lock lock_; | 197 Lock lock_; |
| 200 | 198 |
| 201 // PushSource role is to buffer and it's only used in regular latency mode. | 199 // PushSource role is to buffer and it's only used in regular latency mode. |
| 202 PushSource push_source_; | 200 PushSource push_source_; |
| 203 uint32 buffer_capacity_; | 201 uint32 buffer_capacity_; |
| 204 | 202 |
| 205 // SyncReader is used only in low latency mode for synchronous reading. | 203 // SyncReader is used only in low latency mode for synchronous reading. |
| 206 SyncReader* sync_reader_; | 204 SyncReader* sync_reader_; |
| 207 | 205 |
| 208 // The message loop of audio thread that this object runs on. | 206 // The audio controller thread that this object runs on. |
| 209 MessageLoop* message_loop_; | 207 base::Thread thread_; |
| 210 | 208 |
| 211 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 209 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 212 }; | 210 }; |
| 213 | 211 |
| 214 } // namespace media | 212 } // namespace media |
| 215 | 213 |
| 216 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 214 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |