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

Unified 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: Code review. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/mac/audio_low_latency_input_mac.h
diff --git a/media/audio/mac/audio_low_latency_input_mac.h b/media/audio/mac/audio_low_latency_input_mac.h
index c66c8143f39aa4365121f04d52f79a65de8e352c..7b97760807afa0f138f1d34752f649f88f671a55 100644
--- a/media/audio/mac/audio_low_latency_input_mac.h
+++ b/media/audio/mac/audio_low_latency_input_mac.h
@@ -164,6 +164,13 @@ class MEDIA_EXPORT AUAudioInputStream
// filters out some that make sense to add to UMA stats.
void AddDevicePropertyChangesToUMA(bool startup_failed);
+ // Updates capture timestamp, current lost frames, and total lost frames and
+ // glitches.
+ void UpdateCaptureTimestamp(const AudioTimeStamp* timestamp);
+
+ // Called from the dtor and when the stream is reset.
+ void ReportAndResetStats();
+
// Verifies that Open(), Start(), Stop() and Close() are all called on the
// creating thread which is the main browser thread (CrBrowserMain) on Mac.
base::ThreadChecker thread_checker_;
@@ -174,6 +181,11 @@ class MEDIA_EXPORT AUAudioInputStream
// Contains the desired number of audio frames in each callback.
const size_t number_of_frames_;
+ // Stores the number of frames that we actually get callbacks for.
+ // This may be different from what we ask for, so we use this for stats in
+ // order to understand how often this happens and what are the typical values.
+ size_t number_of_frames_provided_;
+
// The actual I/O buffer size for the input device connected to the active
// AUHAL audio unit.
size_t io_buffer_frame_size_;
@@ -254,6 +266,20 @@ class MEDIA_EXPORT AUAudioInputStream
// Only touched on the creating thread.
bool device_listener_is_active_;
+ // Stores the timestamp of the previous audio buffer provided by the OS.
+ // We use this in combination with |last_number_of_frames_| to detect when
+ // the OS has decided to skip providing frames (i.e. a glitch).
+ // This can happen in case of high CPU load or excessive blocking on the
+ // callback audio thread.
+ // These variables are only touched on the callback thread and then read
+ // in the dtor (when no longer receiving callbacks).
+ // NOTE: Float64 and UInt32 types are used for native API compatibility.
+ Float64 last_sample_time_;
+ UInt32 last_number_of_frames_;
+ UInt32 total_lost_frames_;
+ UInt32 largest_glitch_frames_;
+ int glitches_detected_;
+
DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream);
};

Powered by Google App Engine
This is Rietveld 408576698