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

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

Issue 1736973002: Add UMA stats for OS input glitches on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix. Created 4 years, 9 months 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
OLDNEW
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 // Implementation of AudioInputStream for Mac OS X using the special AUHAL 5 // Implementation of AudioInputStream for Mac OS X using the special AUHAL
6 // input Audio Unit present in OS 10.4 and later. 6 // input Audio Unit present in OS 10.4 and later.
7 // The AUHAL input Audio Unit is for low-latency audio I/O. 7 // The AUHAL input Audio Unit is for low-latency audio I/O.
8 // 8 //
9 // Overview of operation: 9 // Overview of operation:
10 // 10 //
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // Uninitializes the audio unit if needed. 157 // Uninitializes the audio unit if needed.
158 void CloseAudioUnit(); 158 void CloseAudioUnit();
159 159
160 // Adds extra UMA stats when it has been detected that startup failed. 160 // Adds extra UMA stats when it has been detected that startup failed.
161 void AddHistogramsForFailedStartup(); 161 void AddHistogramsForFailedStartup();
162 162
163 // Scans the map of all available property changes (notification types) and 163 // Scans the map of all available property changes (notification types) and
164 // filters out some that make sense to add to UMA stats. 164 // filters out some that make sense to add to UMA stats.
165 void AddDevicePropertyChangesToUMA(bool startup_failed); 165 void AddDevicePropertyChangesToUMA(bool startup_failed);
166 166
167 // Updates capture timestamp, current lost frames, and total lost frames and
168 // glitches.
169 void UpdateCaptureTimestamp(const AudioTimeStamp* timestamp);
170
171 // Called from the dtor and when the stream is reset.
172 void ReportAndResetStats();
173
167 // Verifies that Open(), Start(), Stop() and Close() are all called on the 174 // Verifies that Open(), Start(), Stop() and Close() are all called on the
168 // creating thread which is the main browser thread (CrBrowserMain) on Mac. 175 // creating thread which is the main browser thread (CrBrowserMain) on Mac.
169 base::ThreadChecker thread_checker_; 176 base::ThreadChecker thread_checker_;
170 177
171 // Our creator, the audio manager needs to be notified when we close. 178 // Our creator, the audio manager needs to be notified when we close.
172 AudioManagerMac* const manager_; 179 AudioManagerMac* const manager_;
173 180
174 // Contains the desired number of audio frames in each callback. 181 // Contains the desired number of audio frames in each callback.
175 const size_t number_of_frames_; 182 const size_t number_of_frames_;
176 183
184 // Stores the number of frames that we actually get callbacks for.
185 // This may be different from what we ask for, so we use this for stats in
186 // order to understand how often this happens and what are the typical values.
187 size_t number_of_frames_requested_;
188
177 // The actual I/O buffer size for the input device connected to the active 189 // The actual I/O buffer size for the input device connected to the active
178 // AUHAL audio unit. 190 // AUHAL audio unit.
179 size_t io_buffer_frame_size_; 191 size_t io_buffer_frame_size_;
180 192
181 // Pointer to the object that will receive the recorded audio samples. 193 // Pointer to the object that will receive the recorded audio samples.
182 AudioInputCallback* sink_; 194 AudioInputCallback* sink_;
183 195
184 // Structure that holds the desired output format of the stream. 196 // Structure that holds the desired output format of the stream.
185 // Note that, this format can differ from the device(=input) format. 197 // Note that, this format can differ from the device(=input) format.
186 AudioStreamBasicDescription format_; 198 AudioStreamBasicDescription format_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // added to the queue. The currently executing task runs on a distinct thread 259 // added to the queue. The currently executing task runs on a distinct thread
248 // (which can vary from task to task) that is managed by the dispatch queue. 260 // (which can vary from task to task) that is managed by the dispatch queue.
249 // The map is always read on the creating thread but only while the notifier 261 // The map is always read on the creating thread but only while the notifier
250 // is disabled, hence no lock is required. 262 // is disabled, hence no lock is required.
251 std::map<UInt32, int> device_property_changes_map_; 263 std::map<UInt32, int> device_property_changes_map_;
252 264
253 // Set to true when we are listening for changes in device properties. 265 // Set to true when we are listening for changes in device properties.
254 // Only touched on the creating thread. 266 // Only touched on the creating thread.
255 bool device_listener_is_active_; 267 bool device_listener_is_active_;
256 268
269 // Stores the timestamp of the previous audio buffer provided by the OS.
270 // We use this in combination with |last_number_of_frames_| to detect when
271 // the OS has decided to skip providing frames (i.e. a glitch).
272 // This can happen in case of high CPU load or excessive blocking on the
273 // callback audio thread.
274 // These variables are only touched on the callback thread and then read
Henrik Grunell 2016/02/25 14:40:23 They're also read in Stop(), same as on output sid
tommi (sloooow) - chröme 2016/02/26 10:07:20 It's safe as long as the callbacks aren't active w
Henrik Grunell 2016/02/29 17:48:48 Acknowledged.
275 // in the dtor (when no longer receiving callbacks).
276 // NOTE: Float64 and UInt32 types are used for native API compatibility.
277 Float64 last_sample_time_;
278 UInt32 last_number_of_frames_;
279 UInt32 total_lost_frames_;
280 UInt32 largest_glitch_frames_;
281 int glitches_detected_;
282
257 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); 283 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
258 }; 284 };
259 285
260 } // namespace media 286 } // namespace media
261 287
262 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ 288 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698