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 // Updates playout timestamp, current lost frames, and total lost frames and | |
130 // glitches. | |
131 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); | 129 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); |
132 | 130 |
133 // Called from the dtor and when the stream is reset. | 131 // Called from the dtor and when the stream is reset. |
134 void ReportAndResetStats(); | 132 void ReportAndResetStats(); |
135 | 133 |
136 // Our creator, the audio manager needs to be notified when we close. | 134 // Our creator, the audio manager needs to be notified when we close. |
137 AudioManagerMac* const manager_; | 135 AudioManagerMac* const manager_; |
138 | 136 |
139 const AudioParameters params_; | 137 const AudioParameters params_; |
140 // For convenience - same as in params_. | 138 // For convenience - same as in params_. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 175 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
178 scoped_ptr<AudioBus> output_bus_; | 176 scoped_ptr<AudioBus> output_bus_; |
179 | 177 |
180 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame | 178 // Dynamically allocated FIFO used when CoreAudio asks for unexpected frame |
181 // sizes. | 179 // sizes. |
182 scoped_ptr<AudioPullFifo> audio_fifo_; | 180 scoped_ptr<AudioPullFifo> audio_fifo_; |
183 | 181 |
184 // Current buffer delay. Set by Render(). | 182 // Current buffer delay. Set by Render(). |
185 uint32 current_hardware_pending_bytes_; | 183 uint32 current_hardware_pending_bytes_; |
186 | 184 |
187 // Lost frames not yet reported to the provider. Increased in | |
188 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to | |
189 // the provider and reset in ProvideInput(). | |
190 uint32_t current_lost_frames_; | |
191 | |
192 // Stores the timestamp of the previous audio buffer requested by the OS. | 185 // Stores the timestamp of the previous audio buffer requested by the OS. |
193 // We use this in combination with |last_number_of_frames_| to detect when | 186 // We use this in combination with |last_number_of_frames_| to detect when |
194 // the OS has decided to skip rendering frames (i.e. a glitch). | 187 // the OS has decided to skip rendering frames (i.e. a glitch). |
195 // This can happen in case of high CPU load or excessive blocking on the | 188 // This can happen in case of high CPU load or excessive blocking on the |
196 // callback audio thread. | 189 // callback audio thread. |
197 // These variables are only touched on the callback thread and then read | 190 // These variables are only touched on the callback thread and then read |
198 // in the dtor (when no longer receiving callbacks). | 191 // in the dtor (when no longer receiving callbacks). |
199 // NOTE: Float64 and UInt32 types are used for native API compatibility. | 192 // NOTE: Float64 and UInt32 types are used for native API compatibility. |
200 Float64 last_sample_time_; | 193 Float64 last_sample_time_; |
201 UInt32 last_number_of_frames_; | 194 UInt32 last_number_of_frames_; |
202 UInt32 total_lost_frames_; | 195 UInt32 total_lost_frames_; |
203 UInt32 largest_glitch_frames_; | 196 UInt32 largest_glitch_frames_; |
204 int glitches_detected_; | 197 int glitches_detected_; |
205 | 198 |
206 // Used to defer Start() to workaround http://crbug.com/160920. | 199 // Used to defer Start() to workaround http://crbug.com/160920. |
207 base::CancelableClosure deferred_start_cb_; | 200 base::CancelableClosure deferred_start_cb_; |
208 | 201 |
209 // Used to make sure control functions (Start(), Stop() etc) are called on the | 202 // Used to make sure control functions (Start(), Stop() etc) are called on the |
210 // right thread. | 203 // right thread. |
211 base::ThreadChecker thread_checker_; | 204 base::ThreadChecker thread_checker_; |
212 | 205 |
213 DISALLOW_COPY_AND_ASSIGN(AUHALStream); | 206 DISALLOW_COPY_AND_ASSIGN(AUHALStream); |
214 }; | 207 }; |
215 | 208 |
216 } // namespace media | 209 } // namespace media |
217 | 210 |
218 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ | 211 #endif // MEDIA_AUDIO_MAC_AUDIO_AUHAL_MAC_H_ |
OLD | NEW |