| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 NON_EXPORTED_BASE(public AudioManager::AudioDeviceListener) { | 68 NON_EXPORTED_BASE(public AudioManager::AudioDeviceListener) { |
| 69 public: | 69 public: |
| 70 // An event handler that receives events from the AudioOutputController. The | 70 // An event handler that receives events from the AudioOutputController. The |
| 71 // following methods are called on the audio manager thread. | 71 // following methods are called on the audio manager thread. |
| 72 class MEDIA_EXPORT EventHandler { | 72 class MEDIA_EXPORT EventHandler { |
| 73 public: | 73 public: |
| 74 virtual void OnCreated() = 0; | 74 virtual void OnCreated() = 0; |
| 75 virtual void OnPlaying() = 0; | 75 virtual void OnPlaying() = 0; |
| 76 virtual void OnAudible(bool is_audible) = 0; | 76 virtual void OnAudible(bool is_audible) = 0; |
| 77 virtual void OnPaused() = 0; | 77 virtual void OnPaused() = 0; |
| 78 virtual void OnError(int error_code) = 0; | 78 virtual void OnError() = 0; |
| 79 virtual void OnDeviceChange(int new_buffer_size, int new_sample_rate) = 0; | 79 virtual void OnDeviceChange(int new_buffer_size, int new_sample_rate) = 0; |
| 80 | 80 |
| 81 protected: | 81 protected: |
| 82 virtual ~EventHandler() {} | 82 virtual ~EventHandler() {} |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // A synchronous reader interface used by AudioOutputController for | 85 // A synchronous reader interface used by AudioOutputController for |
| 86 // synchronous reading. | 86 // synchronous reading. |
| 87 // TODO(crogers): find a better name for this class and the Read() method | 87 // TODO(crogers): find a better name for this class and the Read() method |
| 88 // now that it can handle synchronized I/O. | 88 // now that it can handle synchronized I/O. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // Sets the volume of the audio output stream. | 140 // Sets the volume of the audio output stream. |
| 141 void SetVolume(double volume); | 141 void SetVolume(double volume); |
| 142 | 142 |
| 143 // AudioSourceCallback implementation. | 143 // AudioSourceCallback implementation. |
| 144 virtual int OnMoreData(AudioBus* dest, | 144 virtual int OnMoreData(AudioBus* dest, |
| 145 AudioBuffersState buffers_state) OVERRIDE; | 145 AudioBuffersState buffers_state) OVERRIDE; |
| 146 virtual int OnMoreIOData(AudioBus* source, | 146 virtual int OnMoreIOData(AudioBus* source, |
| 147 AudioBus* dest, | 147 AudioBus* dest, |
| 148 AudioBuffersState buffers_state) OVERRIDE; | 148 AudioBuffersState buffers_state) OVERRIDE; |
| 149 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | 149 virtual void OnError(AudioOutputStream* stream) OVERRIDE; |
| 150 // Deprecated: Currently only used for starting audio playback and for audio | 150 // Deprecated: Currently only used for starting audio playback and for audio |
| 151 // mirroring. | 151 // mirroring. |
| 152 virtual void WaitTillDataReady() OVERRIDE; | 152 virtual void WaitTillDataReady() OVERRIDE; |
| 153 | 153 |
| 154 // AudioDeviceListener implementation. When called AudioOutputController will | 154 // AudioDeviceListener implementation. When called AudioOutputController will |
| 155 // shutdown the existing |stream_|, transition to the kRecreating state, | 155 // shutdown the existing |stream_|, transition to the kRecreating state, |
| 156 // create a new stream, and then transition back to an equivalent state prior | 156 // create a new stream, and then transition back to an equivalent state prior |
| 157 // to being called. | 157 // to being called. |
| 158 virtual void OnDeviceChange() OVERRIDE; | 158 virtual void OnDeviceChange() OVERRIDE; |
| 159 | 159 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 186 const AudioParameters& params, SyncReader* sync_reader); | 186 const AudioParameters& params, SyncReader* sync_reader); |
| 187 | 187 |
| 188 // The following methods are executed on the audio manager thread. | 188 // The following methods are executed on the audio manager thread. |
| 189 void DoCreate(bool is_for_device_change); | 189 void DoCreate(bool is_for_device_change); |
| 190 void DoPlay(); | 190 void DoPlay(); |
| 191 void PollAndStartIfDataReady(); | 191 void PollAndStartIfDataReady(); |
| 192 void DoPause(); | 192 void DoPause(); |
| 193 void DoFlush(); | 193 void DoFlush(); |
| 194 void DoClose(); | 194 void DoClose(); |
| 195 void DoSetVolume(double volume); | 195 void DoSetVolume(double volume); |
| 196 void DoReportError(int code); | 196 void DoReportError(); |
| 197 void DoStartDiverting(AudioOutputStream* to_stream); | 197 void DoStartDiverting(AudioOutputStream* to_stream); |
| 198 void DoStopDiverting(); | 198 void DoStopDiverting(); |
| 199 | 199 |
| 200 // Called at regular intervals during playback to check for a change in | 200 // Called at regular intervals during playback to check for a change in |
| 201 // silence and call EventHandler::OnAudible() when state changes occur. | 201 // silence and call EventHandler::OnAudible() when state changes occur. |
| 202 void MaybeInvokeAudibleCallback(); | 202 void MaybeInvokeAudibleCallback(); |
| 203 | 203 |
| 204 // Helper methods that start/stop physical stream. | 204 // Helper methods that start/stop physical stream. |
| 205 void StartStream(); | 205 void StartStream(); |
| 206 void StopStream(); | 206 void StopStream(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // EventHandler::OnAudbile() to be called whenever a transition to a period of | 257 // EventHandler::OnAudbile() to be called whenever a transition to a period of |
| 258 // silence or non-silence is detected. | 258 // silence or non-silence is detected. |
| 259 scoped_ptr<AudioSilenceDetector> silence_detector_; | 259 scoped_ptr<AudioSilenceDetector> silence_detector_; |
| 260 | 260 |
| 261 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 261 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 262 }; | 262 }; |
| 263 | 263 |
| 264 } // namespace media | 264 } // namespace media |
| 265 | 265 |
| 266 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 266 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |