Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: media/audio/mac/audio_auhal_mac.h

Issue 1538563002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fix. git cl format. Rebase. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/fake_audio_output_stream.cc ('k') | media/audio/mac/audio_auhal_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
129 void UpdatePlayoutTimestamp(const AudioTimeStamp* timestamp); 131 void UpdatePlayoutTimestamp(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_.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // UpdatePlayoutTimestamp() if any lost frame since last time. Forwarded to
189 // 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_
OLDNEW
« no previous file with comments | « media/audio/fake_audio_output_stream.cc ('k') | media/audio/mac/audio_auhal_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698