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

Commit 29a705f0 authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "Spatializer: Log latency requests to/from output sink" into tm-qpr-dev am: c7b621a9

parents f5789503 c7b621a9
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -269,6 +269,23 @@ static std::string patchSourcesToString(const struct audio_patch *patch)
    return ss.str();
}

static std::string toString(audio_latency_mode_t mode) {
    // We convert to the AIDL type to print (eventually the legacy type will be removed).
    const auto result = legacy2aidl_audio_latency_mode_t_LatencyMode(mode);
    return result.has_value() ? media::toString(*result) : "UNKNOWN";
}

// Could be made a template, but other toString overloads for std::vector are confused.
static std::string toString(const std::vector<audio_latency_mode_t>& elements) {
    std::string s("{ ");
    for (const auto& e : elements) {
        s.append(toString(e));
        s.append(" ");
    }
    s.append("}");
    return s;
}

static pthread_once_t sFastTrackMultiplierOnce = PTHREAD_ONCE_INIT;

static void sFastTrackMultiplierInit()
@@ -7354,10 +7371,13 @@ status_t AudioFlinger::SpatializerThread::createAudioPatch_l(const struct audio_

void AudioFlinger::SpatializerThread::updateHalSupportedLatencyModes_l() {
    std::vector<audio_latency_mode_t> latencyModes;
    if (mOutput->stream->getRecommendedLatencyModes(&latencyModes) != NO_ERROR) {
    const status_t status = mOutput->stream->getRecommendedLatencyModes(&latencyModes);
    if (status != NO_ERROR) {
        latencyModes.clear();
    }
    if (latencyModes != mSupportedLatencyModes) {
        ALOGD("%s: thread(%d) status %d supported latency modes: %s",
            __func__, mId, status, toString(latencyModes).c_str());
        mSupportedLatencyModes.swap(latencyModes);
        sendHalLatencyModesChangedEvent_l();
    }
@@ -7397,6 +7417,8 @@ void AudioFlinger::SpatializerThread::setHalLatencyMode_l() {

    if (latencyMode != mSetLatencyMode) {
        status_t status = mOutput->stream->setLatencyMode(latencyMode);
        ALOGD("%s: thread(%d) setLatencyMode(%s) returned %d",
                __func__, mId, toString(latencyMode).c_str(), status);
        if (status == NO_ERROR) {
            mSetLatencyMode = latencyMode;
        }
+4 −1
Original line number Diff line number Diff line
@@ -963,7 +963,10 @@ void Spatializer::checkSensorsState_l() {
        }
    }
    if (mOutput != AUDIO_IO_HANDLE_NONE && supportsSetLatencyMode) {
        const status_t status =
                AudioSystem::setRequestedLatencyMode(mOutput, requestedLatencyMode);
        ALOGD("%s: setRequestedLatencyMode for output thread(%d) to %s returned %d",
                __func__, mOutput, toString(requestedLatencyMode).c_str(), status);
    }
}

+4 −8
Original line number Diff line number Diff line
@@ -165,14 +165,10 @@ class Spatializer : public media::BnSpatializer,
    std::string toString(unsigned level) const NO_THREAD_SAFETY_ANALYSIS;

    static std::string toString(audio_latency_mode_t mode) {
        switch (mode) {
            case AUDIO_LATENCY_MODE_FREE:
                return "LATENCY_MODE_FREE";
            case AUDIO_LATENCY_MODE_LOW:
                return "LATENCY_MODE_LOW";
        // We convert to the AIDL type to print (eventually the legacy type will be removed).
        const auto result = legacy2aidl_audio_latency_mode_t_LatencyMode(mode);
        return result.has_value() ? media::toString(*result) : "unknown_latency_mode";
    }
        return "EnumNotImplemented";
    };

    /**
     * Format head to stage vector to a string, [0.00, 0.00, 0.00, -1.29, -0.50, 15.27].