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

Commit 5fbadc89 authored by Robert Wu's avatar Robert Wu
Browse files

AAudio: Use one SRC per shared stream.

In ag/23541584, SRC was added to AAudio.
This caused issues with timestamps in shared streams.

We should use the default sample rate for the shared MMAP endpoint.
This way, each shared stream can use its own SRC.

Bug: 378766408
Test: atest AAudioTests
Test: OboeTester Test Output with shared stream and SRC
Flag: EXEMPT bugfix
Change-Id: I15c31630e770fb9ba75bfb30d41af568d386041f
parent 5b18b370
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ aaudio_result_t AAudioServiceEndpointShared::open(const aaudio::AAudioStreamRequ

    builder.setBufferCapacity(DEFAULT_BUFFER_CAPACITY);

    // Each shared stream will use its own SRC.
    builder.setSampleRate(AAUDIO_UNSPECIFIED);

    result = mStreamInternal->open(builder);

    setSampleRate(mStreamInternal->getSampleRate());
+3 −10
Original line number Diff line number Diff line
@@ -144,6 +144,9 @@ aaudio_result_t AAudioServiceStreamShared::open(const aaudio::AAudioStreamReques
        goto error;
    }

    // Use the sample rate of the endpoint as each shared stream should use its own SRC.
    setSampleRate(endpoint->getSampleRate());

    // Is the request compatible with the shared endpoint?
    setFormat(configurationInput.getFormat());
    if (getFormat() == AUDIO_FORMAT_DEFAULT) {
@@ -154,16 +157,6 @@ aaudio_result_t AAudioServiceStreamShared::open(const aaudio::AAudioStreamReques
        goto error;
    }

    setSampleRate(configurationInput.getSampleRate());
    if (getSampleRate() == AAUDIO_UNSPECIFIED) {
        setSampleRate(endpoint->getSampleRate());
    } else if (getSampleRate() != endpoint->getSampleRate()) {
        ALOGD("%s() mSampleRate = %d, need %d",
              __func__, getSampleRate(), endpoint->getSampleRate());
        result = AAUDIO_ERROR_INVALID_RATE;
        goto error;
    }

    setChannelMask(configurationInput.getChannelMask());
    if (getChannelMask() == AAUDIO_UNSPECIFIED) {
        setChannelMask(endpoint->getChannelMask());