| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // A synchronous reader interface used by AudioOutputController for | 75 // A synchronous reader interface used by AudioOutputController for |
| 76 // synchronous reading. | 76 // synchronous reading. |
| 77 // TODO(crogers): find a better name for this class and the Read() method | 77 // TODO(crogers): find a better name for this class and the Read() method |
| 78 // now that it can handle synchronized I/O. | 78 // now that it can handle synchronized I/O. |
| 79 class SyncReader { | 79 class SyncReader { |
| 80 public: | 80 public: |
| 81 virtual ~SyncReader() {} | 81 virtual ~SyncReader() {} |
| 82 | 82 |
| 83 // Notify the synchronous reader the number of bytes in the | 83 // Notify the synchronous reader the number of bytes in the |
| 84 // AudioOutputController not yet played. This is used by SyncReader to | 84 // AudioOutputController not yet played. This is used by SyncReader to |
| 85 // prepare more data and perform synchronization. | 85 // prepare more data and perform synchronization. Also inform about if any |
| 86 virtual void UpdatePendingBytes(uint32 bytes) = 0; | 86 // frames has been skipped by the consumer. The source can handle this |
| 87 // appropriately depending on the type of source. An ordinary file playout |
| 88 // would ignore this. |
| 89 virtual void UpdatePendingBytes(uint32_t bytes, |
| 90 uint32_t frames_skipped) = 0; |
| 87 | 91 |
| 88 // Attempts to completely fill |dest|, zeroing |dest| if the request can not | 92 // Attempts to completely fill |dest|, zeroing |dest| if the request can not |
| 89 // be fulfilled (due to timeout). | 93 // be fulfilled (due to timeout). |
| 90 virtual void Read(AudioBus* dest) = 0; | 94 virtual void Read(AudioBus* dest) = 0; |
| 91 | 95 |
| 92 // Close this synchronous reader. | 96 // Close this synchronous reader. |
| 93 virtual void Close() = 0; | 97 virtual void Close() = 0; |
| 94 }; | 98 }; |
| 95 | 99 |
| 96 // Factory method for creating an AudioOutputController. | 100 // Factory method for creating an AudioOutputController. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // Changing the output device causes the controller to go through | 151 // Changing the output device causes the controller to go through |
| 148 // the same state transition back to the current state as a call to | 152 // the same state transition back to the current state as a call to |
| 149 // OnDeviceChange (unless it is currently diverting, see | 153 // OnDeviceChange (unless it is currently diverting, see |
| 150 // Start/StopDiverting below, in which case the state transition | 154 // Start/StopDiverting below, in which case the state transition |
| 151 // will happen when StopDiverting is called). | 155 // will happen when StopDiverting is called). |
| 152 void SwitchOutputDevice(const std::string& output_device_id, | 156 void SwitchOutputDevice(const std::string& output_device_id, |
| 153 const base::Closure& callback); | 157 const base::Closure& callback); |
| 154 | 158 |
| 155 // AudioSourceCallback implementation. | 159 // AudioSourceCallback implementation. |
| 156 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override; | 160 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override; |
| 161 void OnSkippedData(uint32 frames_skipped) override; |
| 157 void OnError(AudioOutputStream* stream) override; | 162 void OnError(AudioOutputStream* stream) override; |
| 158 | 163 |
| 159 // AudioDeviceListener implementation. When called AudioOutputController will | 164 // AudioDeviceListener implementation. When called AudioOutputController will |
| 160 // shutdown the existing |stream_|, transition to the kRecreating state, | 165 // shutdown the existing |stream_|, transition to the kRecreating state, |
| 161 // create a new stream, and then transition back to an equivalent state prior | 166 // create a new stream, and then transition back to an equivalent state prior |
| 162 // to being called. | 167 // to being called. |
| 163 void OnDeviceChange() override; | 168 void OnDeviceChange() override; |
| 164 | 169 |
| 165 // AudioSourceDiverter implementation. | 170 // AudioSourceDiverter implementation. |
| 166 const AudioParameters& GetAudioParameters() override; | 171 const AudioParameters& GetAudioParameters() override; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Flag which indicates errors received during Stop/Close should be ignored. | 256 // Flag which indicates errors received during Stop/Close should be ignored. |
| 252 // These errors are generally harmless since a fresh stream is about to be | 257 // These errors are generally harmless since a fresh stream is about to be |
| 253 // recreated, but if forwarded, renderer side clients may consider them | 258 // recreated, but if forwarded, renderer side clients may consider them |
| 254 // catastrophic and abort their operations. | 259 // catastrophic and abort their operations. |
| 255 // | 260 // |
| 256 // If |stream_| is started then |ignore_errors_during_stop_close_| must only | 261 // If |stream_| is started then |ignore_errors_during_stop_close_| must only |
| 257 // be accessed while |error_lock_| is held. | 262 // be accessed while |error_lock_| is held. |
| 258 bool ignore_errors_during_stop_close_; | 263 bool ignore_errors_during_stop_close_; |
| 259 base::Lock error_lock_; | 264 base::Lock error_lock_; |
| 260 | 265 |
| 266 // Stores the number of skipped frames reported in OnSkippedData(), passed on |
| 267 // to the provider in OnMoreData(). |
| 268 uint32_t frames_skipped_; |
| 269 |
| 261 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 270 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
| 262 }; | 271 }; |
| 263 | 272 |
| 264 } // namespace media | 273 } // namespace media |
| 265 | 274 |
| 266 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 275 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
| OLD | NEW |