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/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // The AudioOutputStream can request data from the AudioOutputController via the | 56 // The AudioOutputStream can request data from the AudioOutputController via the |
57 // AudioSourceCallback interface. AudioOutputController uses the SyncReader | 57 // AudioSourceCallback interface. AudioOutputController uses the SyncReader |
58 // passed to it via construction to synchronously fulfill this read request. | 58 // passed to it via construction to synchronously fulfill this read request. |
59 // | 59 // |
60 // Since AudioOutputController uses AudioManager's message loop the controller | 60 // Since AudioOutputController uses AudioManager's message loop the controller |
61 // uses WeakPtr to allow safe cancellation of pending tasks. | 61 // uses WeakPtr to allow safe cancellation of pending tasks. |
62 // | 62 // |
63 | 63 |
64 namespace media { | 64 namespace media { |
65 | 65 |
| 66 // TODO(miu): STUB |
| 67 class DivertedAudioOutputStream : public AudioOutputStream { |
| 68 }; |
| 69 |
66 class MEDIA_EXPORT AudioOutputController | 70 class MEDIA_EXPORT AudioOutputController |
67 : public base::RefCountedThreadSafe<AudioOutputController>, | 71 : public base::RefCountedThreadSafe<AudioOutputController>, |
68 public AudioOutputStream::AudioSourceCallback, | 72 public AudioOutputStream::AudioSourceCallback, |
69 NON_EXPORTED_BASE(public AudioManager::AudioDeviceListener) { | 73 NON_EXPORTED_BASE(public AudioManager::AudioDeviceListener) { |
70 public: | 74 public: |
71 // An event handler that receives events from the AudioOutputController. The | 75 // An event handler that receives events from the AudioOutputController. The |
72 // following methods are called on the audio manager thread. | 76 // following methods are called on the audio manager thread. |
73 class MEDIA_EXPORT EventHandler { | 77 class MEDIA_EXPORT EventHandler { |
74 public: | 78 public: |
75 virtual void OnCreated(AudioOutputController* controller) = 0; | 79 virtual void OnCreated(AudioOutputController* controller) = 0; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 AudioBuffersState buffers_state) OVERRIDE; | 155 AudioBuffersState buffers_state) OVERRIDE; |
152 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | 156 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; |
153 virtual void WaitTillDataReady() OVERRIDE; | 157 virtual void WaitTillDataReady() OVERRIDE; |
154 | 158 |
155 // AudioDeviceListener implementation. When called AudioOutputController will | 159 // AudioDeviceListener implementation. When called AudioOutputController will |
156 // shutdown the existing |stream_|, transition to the kRecreating state, | 160 // shutdown the existing |stream_|, transition to the kRecreating state, |
157 // create a new stream, and then transition back to an equivalent state prior | 161 // create a new stream, and then transition back to an equivalent state prior |
158 // to being called. | 162 // to being called. |
159 virtual void OnDeviceChange() OVERRIDE; | 163 virtual void OnDeviceChange() OVERRIDE; |
160 | 164 |
| 165 // Creates a DivertedAudioOutputStream and diverts audio data to it, away from |
| 166 // the existing AudioOutputStream. A call to Revert() restores the previous, |
| 167 // normal audio data flow. |
| 168 DivertedAudioOutputStream* Divert(); |
| 169 |
| 170 // Restores the previous, normal audio data flow (i.e., the state of the |
| 171 // stream before Divert() was called). |aos| is destroyed. |
| 172 void Revert(DivertedAudioOutputStream* aos); |
| 173 |
161 protected: | 174 protected: |
162 // Internal state of the source. | 175 // Internal state of the source. |
163 enum State { | 176 enum State { |
164 kEmpty, | 177 kEmpty, |
165 kCreated, | 178 kCreated, |
166 kPlaying, | 179 kPlaying, |
167 kStarting, | 180 kStarting, |
168 kPausedWhenStarting, | 181 kPausedWhenStarting, |
169 kPaused, | 182 kPaused, |
170 kClosed, | 183 kClosed, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // shutdown and force it to wait for the most delayed task. | 248 // shutdown and force it to wait for the most delayed task. |
236 // Also, if we're shutting down, we do not want to poll for more data. | 249 // Also, if we're shutting down, we do not want to poll for more data. |
237 base::WeakPtrFactory<AudioOutputController> weak_this_; | 250 base::WeakPtrFactory<AudioOutputController> weak_this_; |
238 | 251 |
239 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 252 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
240 }; | 253 }; |
241 | 254 |
242 } // namespace media | 255 } // namespace media |
243 | 256 |
244 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 257 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
OLD | NEW |