Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d47aca24 authored by Andy Hung's avatar Andy Hung
Browse files

AudioPolicy: Log the construction duration to mediametrics

The initialization time can be quite significant,
6-7s on a Pixel 6.

Test: adb shell dumpsys media.metrics
Bug: 219958414
Change-Id: I0c08f7137b8c77b88636a4919b16c6435e31eac2
parent fda15906
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -114,6 +114,13 @@ void AudioPolicyService::loadAudioPolicyManager()

void AudioPolicyService::onFirstRef()
{
    // Log an AudioPolicy "constructor" mediametrics event on first ref.
    // This records the time it takes to load the audio modules and devices.
    mediametrics::Defer defer([beginNs = systemTime()] {
        mediametrics::LogItem(AMEDIAMETRICS_KEY_AUDIO_POLICY)
            .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR)
            .set(AMEDIAMETRICS_PROP_EXECUTIONTIMENS, (int64_t)(systemTime() - beginNs))
            .record(); });
    {
        Mutex::Autolock _l(mLock);