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

Commit 090f68aa authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge changes I659d9643,Ib122c90b

* changes:
  MediaMetrics: Fix inaccurate attribution of thread device
  Spatializer: Send metrics when not created
parents 05ea0be1 af8b8de3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@
#define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective."
#define AMEDIAMETRICS_PROP_PREFIX_HAL       "hal."
#define AMEDIAMETRICS_PROP_PREFIX_HAPTIC    "haptic."
#define AMEDIAMETRICS_PROP_PREFIX_LAST      "last."
#define AMEDIAMETRICS_PROP_PREFIX_SERVER    "server."

// Properties within mediametrics are string constants denoted by
+8 −1
Original line number Diff line number Diff line
@@ -148,7 +148,14 @@ private:
            item.set(AMEDIAMETRICS_PROP_CUMULATIVETIMENS, mCumulativeTimeNs)
                .set(AMEDIAMETRICS_PROP_DEVICETIMENS, mDeviceTimeNs)
                .set(AMEDIAMETRICS_PROP_EVENT, eventName)
                .set(AMEDIAMETRICS_PROP_INTERVALCOUNT, (int32_t)mIntervalCount);
                .set(AMEDIAMETRICS_PROP_INTERVALCOUNT, (int32_t)mIntervalCount)
                // we set "last" device to indicate the device the group was
                // associated with (because a createPatch which is logged in ThreadMetrics
                // could have changed the device).
                .set(mIsOut
                        ? AMEDIAMETRICS_PROP_PREFIX_LAST AMEDIAMETRICS_PROP_OUTPUTDEVICES
                        : AMEDIAMETRICS_PROP_PREFIX_LAST AMEDIAMETRICS_PROP_INPUTDEVICES,
                        mDevices.c_str());
            if (mDeviceLatencyMs.getN() > 0) {
                item.set(AMEDIAMETRICS_PROP_DEVICELATENCYMS, mDeviceLatencyMs.getMean());
            }
+5 −0
Original line number Diff line number Diff line
@@ -272,6 +272,11 @@ void AudioPolicyService::onFirstRef()
        if (hasSpatializer) {
            mSpatializer = Spatializer::create(this);
        }
        if (mSpatializer == nullptr) {
            // No spatializer created, signal the reason: NO_INIT a failure, OK means intended.
            const status_t createStatus = hasSpatializer ? NO_INIT : OK;
            Spatializer::sendEmptyCreateSpatializerMetricWithStatus(createStatus);
        }
    }
    AudioSystem::audioPolicyReady();
}
+12 −0
Original line number Diff line number Diff line
@@ -387,6 +387,18 @@ status_t Spatializer::loadEngineConfiguration(sp<EffectHalInterface> effect) {
    return NO_ERROR;
}

/* static */
void Spatializer::sendEmptyCreateSpatializerMetricWithStatus(status_t status) {
    mediametrics::LogItem(kDefaultMetricsId)
        .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE)
        .set(AMEDIAMETRICS_PROP_CHANNELMASKS, "")
        .set(AMEDIAMETRICS_PROP_LEVELS, "")
        .set(AMEDIAMETRICS_PROP_MODES, "")
        .set(AMEDIAMETRICS_PROP_HEADTRACKINGMODES, "")
        .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)status)
        .record();
}

/** Gets the channel mask, sampling rate and format set for the spatializer input. */
audio_config_base_t Spatializer::getAudioInConfig() const {
    std::lock_guard lock(mLock);
+8 −1
Original line number Diff line number Diff line
@@ -198,6 +198,11 @@ class Spatializer : public media::BnSpatializer,
        return ss;
    };

    // If the Spatializer is not created, we send the status for metrics purposes.
    // OK:      Spatializer not expected to be created.
    // NO_INIT: Spatializer creation failed.
    static void sendEmptyCreateSpatializerMetricWithStatus(status_t status);

private:
    Spatializer(effect_descriptor_t engineDescriptor,
                     SpatializerPolicyCallback *callback);
@@ -351,7 +356,9 @@ private:
    SpatializerPolicyCallback* const mPolicyCallback;

    /** Currently there is only one version of the spatializer running */
    const std::string mMetricsId = AMEDIAMETRICS_KEY_PREFIX_AUDIO_SPATIALIZER "0";
    static constexpr const char* kDefaultMetricsId =
            AMEDIAMETRICS_KEY_PREFIX_AUDIO_SPATIALIZER "0";
    const std::string mMetricsId = kDefaultMetricsId;

    /** Mutex protecting internal state */
    mutable std::mutex mLock;
Loading