| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 public AudioSourceDiverter, | 63 public AudioSourceDiverter, |
| 64 NON_EXPORTED_BASE(public AudioManager::AudioDeviceListener) { | 64 NON_EXPORTED_BASE(public AudioManager::AudioDeviceListener) { |
| 65 public: | 65 public: |
| 66 // An event handler that receives events from the AudioOutputController. The | 66 // An event handler that receives events from the AudioOutputController. The |
| 67 // following methods are called on the audio manager thread. | 67 // following methods are called on the audio manager thread. |
| 68 class MEDIA_EXPORT EventHandler { | 68 class MEDIA_EXPORT EventHandler { |
| 69 public: | 69 public: |
| 70 virtual void OnCreated(AudioOutputController* controller) = 0; | 70 virtual void OnCreated(AudioOutputController* controller) = 0; |
| 71 virtual void OnPlaying(AudioOutputController* controller) = 0; | 71 virtual void OnPlaying(AudioOutputController* controller) = 0; |
| 72 virtual void OnPaused(AudioOutputController* controller) = 0; | 72 virtual void OnPaused(AudioOutputController* controller) = 0; |
| 73 virtual void OnError(AudioOutputController* controller, int error_code) = 0; | 73 virtual void OnError(AudioOutputController* controller) = 0; |
| 74 virtual void OnDeviceChange(AudioOutputController* controller, | 74 virtual void OnDeviceChange(AudioOutputController* controller, |
| 75 int new_buffer_size, int new_sample_rate) = 0; | 75 int new_buffer_size, int new_sample_rate) = 0; |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 virtual ~EventHandler() {} | 78 virtual ~EventHandler() {} |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // A synchronous reader interface used by AudioOutputController for | 81 // A synchronous reader interface used by AudioOutputController for |
| 82 // synchronous reading. | 82 // synchronous reading. |
| 83 // TODO(crogers): find a better name for this class and the Read() method | 83 // TODO(crogers): find a better name for this class and the Read() method |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 // Sets the volume of the audio output stream. | 136 // Sets the volume of the audio output stream. |
| 137 void SetVolume(double volume); | 137 void SetVolume(double volume); |
| 138 | 138 |
| 139 // AudioSourceCallback implementation. | 139 // AudioSourceCallback implementation. |
| 140 virtual int OnMoreData(AudioBus* dest, | 140 virtual int OnMoreData(AudioBus* dest, |
| 141 AudioBuffersState buffers_state) OVERRIDE; | 141 AudioBuffersState buffers_state) OVERRIDE; |
| 142 virtual int OnMoreIOData(AudioBus* source, | 142 virtual int OnMoreIOData(AudioBus* source, |
| 143 AudioBus* dest, | 143 AudioBus* dest, |
| 144 AudioBuffersState buffers_state) OVERRIDE; | 144 AudioBuffersState buffers_state) OVERRIDE; |
| 145 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | 145 virtual void OnError(AudioOutputStream* stream) OVERRIDE; |
| 146 // Deprecated: Currently only used for starting audio playback and for audio | 146 // Deprecated: Currently only used for starting audio playback and for audio |
| 147 // mirroring. | 147 // mirroring. |
| 148 virtual void WaitTillDataReady() OVERRIDE; | 148 virtual void WaitTillDataReady() OVERRIDE; |
| 149 | 149 |
| 150 // AudioDeviceListener implementation. When called AudioOutputController will | 150 // AudioDeviceListener implementation. When called AudioOutputController will |
| 151 // shutdown the existing |stream_|, transition to the kRecreating state, | 151 // shutdown the existing |stream_|, transition to the kRecreating state, |
| 152 // create a new stream, and then transition back to an equivalent state prior | 152 // create a new stream, and then transition back to an equivalent state prior |
| 153 // to being called. | 153 // to being called. |
| 154 virtual void OnDeviceChange() OVERRIDE; | 154 virtual void OnDeviceChange() OVERRIDE; |
| 155 | 155 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 182 const AudioParameters& params, SyncReader* sync_reader); | 182 const AudioParameters& params, SyncReader* sync_reader); |
| 183 | 183 |
| 184 // The following methods are executed on the audio manager thread. | 184 // The following methods are executed on the audio manager thread. |
| 185 void DoCreate(bool is_for_device_change); | 185 void DoCreate(bool is_for_device_change); |
| 186 void DoPlay(); | 186 void DoPlay(); |
| 187 void PollAndStartIfDataReady(); | 187 void PollAndStartIfDataReady(); |
| 188 void DoPause(); | 188 void DoPause(); |
| 189 void DoFlush(); | 189 void DoFlush(); |
| 190 void DoClose(); | 190 void DoClose(); |
| 191 void DoSetVolume(double volume); | 191 void DoSetVolume(double volume); |
| 192 void DoReportError(int code); | 192 void DoReportError(); |
| 193 void DoStartDiverting(AudioOutputStream* to_stream); | 193 void DoStartDiverting(AudioOutputStream* to_stream); |
| 194 void DoStopDiverting(); | 194 void DoStopDiverting(); |
| 195 | 195 |
| 196 // Helper methods that start/stop physical stream. | 196 // Helper methods that start/stop physical stream. |
| 197 void StartStream(); | 197 void StartStream(); |
| 198 void StopStream(); | 198 void StopStream(); |
| 199 | 199 |
| 200 // Helper method that stops, closes, and NULLs |*stream_|. | 200 // Helper method that stops, closes, and NULLs |*stream_|. |
| 201 void DoStopCloseAndClearStream(); | 201 void DoStopCloseAndClearStream(); |
| 202 | 202 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // Used to auto-cancel the delayed tasks that are created to poll for data | 244 // Used to auto-cancel the delayed tasks that are created to poll for data |
| 245 // (when starting-up a stream). | 245 // (when starting-up a stream). |
| 246 base::WeakPtrFactory<AudioOutputController> weak_this_; | 246 base::WeakPtrFactory<AudioOutputController> weak_this_; |
| 247 | 247 |
| 248 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 248 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 } // namespace media | 251 } // namespace media |
| 252 | 252 |
| 253 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 253 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |