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_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/atomic_ref_count.h" | 8 #include "base/atomic_ref_count.h" |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 const AudioParameters& params, SyncReader* sync_reader); | 115 const AudioParameters& params, SyncReader* sync_reader); |
116 | 116 |
117 // Methods to control playback of the stream. | 117 // Methods to control playback of the stream. |
118 | 118 |
119 // Starts the playback of this audio output stream. | 119 // Starts the playback of this audio output stream. |
120 void Play(); | 120 void Play(); |
121 | 121 |
122 // Pause this audio output stream. | 122 // Pause this audio output stream. |
123 void Pause(); | 123 void Pause(); |
124 | 124 |
125 // Discard all audio data buffered in this output stream. This method only | |
126 // has effect when the stream is paused. | |
127 void Flush(); | |
128 | |
129 // Closes the audio output stream. The state is changed and the resources | 125 // Closes the audio output stream. The state is changed and the resources |
130 // are freed on the audio manager thread. closed_task is executed after that. | 126 // are freed on the audio manager thread. closed_task is executed after that. |
131 // Callbacks (EventHandler and SyncReader) must exist until closed_task is | 127 // Callbacks (EventHandler and SyncReader) must exist until closed_task is |
132 // called. | 128 // called. |
133 // | 129 // |
134 // It is safe to call this method more than once. Calls after the first one | 130 // It is safe to call this method more than once. Calls after the first one |
135 // will have no effect. | 131 // will have no effect. |
136 void Close(const base::Closure& closed_task); | 132 void Close(const base::Closure& closed_task); |
137 | 133 |
138 // Sets the volume of the audio output stream. | 134 // Sets the volume of the audio output stream. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 static const int kPollPauseInMilliseconds; | 177 static const int kPollPauseInMilliseconds; |
182 | 178 |
183 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, | 179 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, |
184 const AudioParameters& params, SyncReader* sync_reader); | 180 const AudioParameters& params, SyncReader* sync_reader); |
185 | 181 |
186 // The following methods are executed on the audio manager thread. | 182 // The following methods are executed on the audio manager thread. |
187 void DoCreate(bool is_for_device_change); | 183 void DoCreate(bool is_for_device_change); |
188 void DoPlay(); | 184 void DoPlay(); |
189 void PollAndStartIfDataReady(); | 185 void PollAndStartIfDataReady(); |
190 void DoPause(); | 186 void DoPause(); |
191 void DoFlush(); | |
192 void DoClose(); | 187 void DoClose(); |
193 void DoSetVolume(double volume); | 188 void DoSetVolume(double volume); |
194 void DoReportError(); | 189 void DoReportError(); |
195 void DoStartDiverting(AudioOutputStream* to_stream); | 190 void DoStartDiverting(AudioOutputStream* to_stream); |
196 void DoStopDiverting(); | 191 void DoStopDiverting(); |
197 | 192 |
198 // Called at regular intervals during playback to check for a change in | 193 // Called at regular intervals during playback to check for a change in |
199 // silence and call EventHandler::OnAudible() when state changes occur. | 194 // silence and call EventHandler::OnAudible() when state changes occur. |
200 void MaybeInvokeAudibleCallback(); | 195 void MaybeInvokeAudibleCallback(); |
201 | 196 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // EventHandler::OnAudbile() to be called whenever a transition to a period of | 250 // EventHandler::OnAudbile() to be called whenever a transition to a period of |
256 // silence or non-silence is detected. | 251 // silence or non-silence is detected. |
257 scoped_ptr<AudioSilenceDetector> silence_detector_; | 252 scoped_ptr<AudioSilenceDetector> silence_detector_; |
258 | 253 |
259 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 254 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
260 }; | 255 }; |
261 | 256 |
262 } // namespace media | 257 } // namespace media |
263 | 258 |
264 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 259 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
OLD | NEW |