Chromium Code Reviews| 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. The caller owns the returned object. When | |
| 167 // the object's destructor is invoked (on the IO thread), the diversion | |
| 168 // reverts. | |
| 169 DivertedAudioOutputStream* Divert(); | |
|
Alpha Left Google
2012/11/20 21:49:43
I think this class should be DAOS.
miu
2012/11/21 08:27:48
Yep. The more I think about it, the more we shoul
| |
| 170 | |
| 161 protected: | 171 protected: |
| 162 // Internal state of the source. | 172 // Internal state of the source. |
| 163 enum State { | 173 enum State { |
| 164 kEmpty, | 174 kEmpty, |
| 165 kCreated, | 175 kCreated, |
| 166 kPlaying, | 176 kPlaying, |
| 167 kStarting, | 177 kStarting, |
| 168 kPausedWhenStarting, | 178 kPausedWhenStarting, |
| 169 kPaused, | 179 kPaused, |
| 170 kClosed, | 180 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. | 245 // 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. | 246 // Also, if we're shutting down, we do not want to poll for more data. |
| 237 base::WeakPtrFactory<AudioOutputController> weak_this_; | 247 base::WeakPtrFactory<AudioOutputController> weak_this_; |
| 238 | 248 |
| 239 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 249 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 240 }; | 250 }; |
| 241 | 251 |
| 242 } // namespace media | 252 } // namespace media |
| 243 | 253 |
| 244 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 254 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |