| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Implementation notes: | 5 // Implementation notes: |
| 6 // | 6 // |
| 7 // - It is recommended to first acquire the native sample rate of the default | 7 // - It is recommended to first acquire the native sample rate of the default |
| 8 // output device and then use the same rate when creating this object. | 8 // output device and then use the same rate when creating this object. |
| 9 // Use AudioManagerMac::HardwareSampleRate() to retrieve the sample rate. | 9 // Use AudioManagerMac::HardwareSampleRate() to retrieve the sample rate. |
| 10 // - Calling Close() also leads to self destruction. | 10 // - Calling Close() also leads to self destruction. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // Creates the input and output busses. | 119 // Creates the input and output busses. |
| 120 void CreateIOBusses(); | 120 void CreateIOBusses(); |
| 121 | 121 |
| 122 // Gets the fixed playout device hardware latency and stores it. Returns 0 | 122 // Gets the fixed playout device hardware latency and stores it. Returns 0 |
| 123 // if not available. | 123 // if not available. |
| 124 double GetHardwareLatency(); | 124 double GetHardwareLatency(); |
| 125 | 125 |
| 126 // Gets the current playout latency value. | 126 // Gets the current playout latency value. |
| 127 double GetPlayoutLatency(const AudioTimeStamp* output_time_stamp); | 127 double GetPlayoutLatency(const AudioTimeStamp* output_time_stamp); |
| 128 | 128 |
| 129 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); | 129 // Updates playout timestamp, current lost frames, and total lost frames and |
| 130 // glitches stats. |
| 131 void UpdatePlayoutTimestampAndStats(const AudioTimeStamp* timestamp); |
| 130 | 132 |
| 131 // Called from the dtor and when the stream is reset. | 133 // Called from the dtor and when the stream is reset. |
| 132 void ReportAndResetStats(); | 134 void ReportAndResetStats(); |
| 133 | 135 |
| 134 // Our creator, the audio manager needs to be notified when we close. | 136 // Our creator, the audio manager needs to be notified when we close. |
| 135 AudioManagerMac* const manager_; | 137 AudioManagerMac* const manager_; |
| 136 | 138 |
| 137 const AudioParameters params_; | 139 const AudioParameters params_; |
| 138 // For convenience - same as in params_. | 140 // For convenience - same as in params_. |
| 139 const int output_channels_; | 141 const int output_channels_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 177 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
| 176 scoped_ptr<AudioBus> output_bus_; | 178 scoped_ptr<AudioBus> output_bus_; |
| 177 | 179 |
| 178 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame | 180 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame |
| 179 // sizes. | 181 // sizes. |
| 180 scoped_ptr<AudioPullFifo> audio_fifo_; | 182 scoped_ptr<AudioPullFifo> audio_fifo_; |
| 181 | 183 |
| 182 // Current buffer delay. Set by Render(). | 184 // Current buffer delay. Set by Render(). |
| 183 uint32 current_hardware_pending_bytes_; | 185 uint32 current_hardware_pending_bytes_; |
| 184 | 186 |
| 187 // Lost frames not yet reported to the provider. Increased in |
| 188 // UpdatePlayoutTimestampAndStats() if any lost frame since last time. |
| 189 // Forwarded to the provider and reset in ProvideInput(). |
| 190 uint32_t current_lost_frames_; |
| 191 |
| 185 // Stores the timestamp of the previous audio buffer requested by the OS. | 192 // Stores the timestamp of the previous audio buffer requested by the OS. |
| 186 // We use this in combination with |last_number_of_frames_| to detect when | 193 // We use this in combination with |last_number_of_frames_| to detect when |
| 187 // the OS has decided to skip rendering frames (i.e. a glitch). | 194 // the OS has decided to skip rendering frames (i.e. a glitch). |
| 188 // This can happen in case of high CPU load or excessive blocking on the | 195 // This can happen in case of high CPU load or excessive blocking on the |
| 189 // callback audio thread. | 196 // callback audio thread. |
| 190 // These variables are only touched on the callback thread and then read | 197 // These variables are only touched on the callback thread and then read |
| 191 // in the dtor (when no longer receiving callbacks). | 198 // in the dtor (when no longer receiving callbacks). |
| 192 // NOTE: Float64 and UInt32 types are used for native API compatibility. | 199 // NOTE: Float64 and UInt32 types are used for native API compatibility. |
| 193 Float64 last_sample_time_; | 200 Float64 last_sample_time_; |
| 194 UInt32 last_number_of_frames_; | 201 UInt32 last_number_of_frames_; |
| 195 UInt32 total_lost_frames_; | 202 UInt32 total_lost_frames_; |
| 196 UInt32 largest_glitch_frames_; | 203 UInt32 largest_glitch_frames_; |
| 197 int glitches_detected_; | 204 int glitches_detected_; |
| 198 | 205 |
| 199 // Used to defer Start() to workaround http://crbug.com/160920. | 206 // Used to defer Start() to workaround http://crbug.com/160920. |
| 200 base::CancelableClosure deferred_start_cb_; | 207 base::CancelableClosure deferred_start_cb_; |
| 201 | 208 |
| 202 // Used to make sure control functions (Start(), Stop() etc) are called on the | 209 // Used to make sure control functions (Start(), Stop() etc) are called on the |
| 203 // right thread. | 210 // right thread. |
| 204 base::ThreadChecker thread_checker_; | 211 base::ThreadChecker thread_checker_; |
| 205 | 212 |
| 206 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 213 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
| 207 }; | 214 }; |
| 208 | 215 |
| 209 } // namespace media | 216 } // namespace media |
| 210 | 217 |
| 211 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 218 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
| OLD | NEW |