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

Commit 55e5eabf authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: cleanup logs and add counters to dumpsys

Counters will give us some history for AAudio.
Removed some unneeded logs.
Added log to help debug intermittent volume problem.

Bug: 64310586
Test: adb shell logcat
Test: adb shell dumpsys media.aaudio
Change-Id: I012361bb4d0d0bfdedfe5ceef856b59282c8d3f0
parent b8bddf5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -501,9 +501,9 @@ aaudio_result_t AudioStreamInternal::onEventFromServer(AAudioServiceMessage *mes
            ALOGW("%s - AAUDIO_SERVICE_EVENT_DISCONNECTED - FIFO cleared", __func__);
            break;
        case AAUDIO_SERVICE_EVENT_VOLUME:
            ALOGD("%s - AAUDIO_SERVICE_EVENT_VOLUME %lf", __func__, message->event.dataDouble);
            mStreamVolume = (float)message->event.dataDouble;
            doSetVolume();
            ALOGD("%s - AAUDIO_SERVICE_EVENT_VOLUME %lf", __func__, message->event.dataDouble);
            break;
        case AAUDIO_SERVICE_EVENT_XRUN:
            mXRunCount = static_cast<int32_t>(message->event.dataLong);
+5 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ aaudio_result_t AudioStreamInternalPlay::processDataNow(void *buffer, int32_t nu
        // Still haven't got any timestamps from server.
        // Keep waiting until we get some valid timestamps then start writing to the
        // current buffer position.
        ALOGD("%s() wait for valid timestamps", __func__);
        ALOGV("%s() wait for valid timestamps", __func__);
        // Sleep very briefly and hope we get a timestamp soon.
        *wakeTimePtr = currentNanoTime + (2000 * AAUDIO_NANOS_PER_MICROSECOND);
        ATRACE_END();
@@ -310,6 +310,9 @@ void *AudioStreamInternalPlay::callbackLoop() {
//------------------------------------------------------------------------------
// Implementation of PlayerBase
status_t AudioStreamInternalPlay::doSetVolume() {
    mVolumeRamp.setTarget(mStreamVolume * getDuckAndMuteVolume());
    float combinedVolume = mStreamVolume * getDuckAndMuteVolume();
    ALOGD("%s() mStreamVolume * duckAndMuteVolume = %f * %f = %f",
          __func__, mStreamVolume, getDuckAndMuteVolume(), combinedVolume);
    mVolumeRamp.setTarget(combinedVolume);
    return android::NO_ERROR;
}
+6 −1
Original line number Diff line number Diff line
@@ -428,6 +428,12 @@ android::media::VolumeShaper::Status AudioStream::applyVolumeShaper(
}
#endif

void AudioStream::setDuckAndMuteVolume(float duckAndMuteVolume) {
    ALOGD("%s() to %f", __func__, duckAndMuteVolume);
    mDuckAndMuteVolume = duckAndMuteVolume;
    doSetVolume(); // apply this change
}

AudioStream::MyPlayerBase::MyPlayerBase(AudioStream *parent) : mParent(parent) {
}

@@ -449,7 +455,6 @@ void AudioStream::MyPlayerBase::unregisterWithAudioManager() {
    }
}


void AudioStream::MyPlayerBase::destroy() {
    unregisterWithAudioManager();
}
+1 −4
Original line number Diff line number Diff line
@@ -328,10 +328,7 @@ public:
    }

    // This is used by the AudioManager to duck and mute the stream when changing audio focus.
    void setDuckAndMuteVolume(float duckAndMuteVolume) {
        mDuckAndMuteVolume = duckAndMuteVolume;
        doSetVolume(); // apply this change
    }
    void setDuckAndMuteVolume(float duckAndMuteVolume);

    float getDuckAndMuteVolume() const {
        return mDuckAndMuteVolume;
+7 −8
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static aaudio_result_t builder_createStream(aaudio_direction_t direction,
            break;

        default:
            ALOGE("bad direction = %d", direction);
            ALOGE("%s() bad direction = %d", __func__, direction);
            result = AAUDIO_ERROR_ILLEGAL_ARGUMENT;
    }
    return result;
@@ -99,7 +99,7 @@ static aaudio_result_t builder_createStream(aaudio_direction_t direction,
aaudio_result_t AudioStreamBuilder::build(AudioStream** streamPtr) {
    AudioStream *audioStream = nullptr;
    if (streamPtr == nullptr) {
        ALOGE("build() streamPtr is null");
        ALOGE("%s() streamPtr is null", __func__);
        return AAUDIO_ERROR_NULL;
    }
    *streamPtr = nullptr;
@@ -124,13 +124,11 @@ aaudio_result_t AudioStreamBuilder::build(AudioStream** streamPtr) {
    if (mapExclusivePolicy == AAUDIO_UNSPECIFIED) {
        mapExclusivePolicy = AAUDIO_MMAP_EXCLUSIVE_POLICY_DEFAULT;
    }
    ALOGD("mmapPolicy = %d, mapExclusivePolicy = %d",
          mmapPolicy, mapExclusivePolicy);

    aaudio_sharing_mode_t sharingMode = getSharingMode();
    if ((sharingMode == AAUDIO_SHARING_MODE_EXCLUSIVE)
        && (mapExclusivePolicy == AAUDIO_POLICY_NEVER)) {
        ALOGW("EXCLUSIVE sharing mode not supported. Use SHARED.");
        ALOGD("%s() EXCLUSIVE sharing mode not supported. Use SHARED.", __func__);
        sharingMode = AAUDIO_SHARING_MODE_SHARED;
        setSharingMode(sharingMode);
    }
@@ -141,13 +139,14 @@ aaudio_result_t AudioStreamBuilder::build(AudioStream** streamPtr) {
    // TODO Support other performance settings in MMAP mode.
    // Disable MMAP if low latency not requested.
    if (getPerformanceMode() != AAUDIO_PERFORMANCE_MODE_LOW_LATENCY) {
        ALOGD("build() MMAP not available because AAUDIO_PERFORMANCE_MODE_LOW_LATENCY not used.");
        ALOGD("%s() MMAP not available because AAUDIO_PERFORMANCE_MODE_LOW_LATENCY not used.",
              __func__);
        allowMMap = false;
    }

    // SessionID and Effects are only supported in Legacy mode.
    if (getSessionId() != AAUDIO_SESSION_ID_NONE) {
        ALOGD("build() MMAP not available because sessionId used.");
        ALOGD("%s() MMAP not available because sessionId used.", __func__);
        allowMMap = false;
    }

@@ -163,7 +162,7 @@ aaudio_result_t AudioStreamBuilder::build(AudioStream** streamPtr) {
            audioStream = nullptr;

            if (isMMap && allowLegacy) {
                ALOGD("build() MMAP stream did not open so try Legacy path");
                ALOGV("%s() MMAP stream did not open so try Legacy path", __func__);
                // If MMAP stream failed to open then TRY using a legacy stream.
                result = builder_createStream(getDirection(), sharingMode,
                                              false, &audioStream);
Loading