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

Commit b7e30fa0 authored by Robert Wu's avatar Robert Wu
Browse files

Don't apply extra AAudio volume ramps

For shared Audio streams, both the exclusive version and the shared version per client will be applying volume changes to the volume ramp.

The fix is to not apply volume changes to shared streams since the exclusive stream will do the ramp.

Bug: 209877538
Test: OboeTester MMAP exclusive/shared
Test: atest AAudioTests
Change-Id: I6172e7ace0b36f84f2a2005e30ad7667e210fe49
parent af0dd0d1
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -42,14 +42,15 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat,
                          audio_format_t sinkFormat,
                          int32_t sinkChannelCount,
                          bool useMonoBlend,
                          float audioBalance) {
                          float audioBalance,
                          bool isExclusive) {
    FlowGraphPortFloatOutput *lastOutput = nullptr;

    // TODO change back to ALOGD
    ALOGI("%s() source format = 0x%08x, channels = %d, sink format = 0x%08x, channels = %d, "
          "useMonoBlend = %d, audioBalance = %f",
          "useMonoBlend = %d, audioBalance = %f, isExclusive %d",
          __func__, sourceFormat, sourceChannelCount, sinkFormat, sinkChannelCount,
          useMonoBlend, audioBalance);
          useMonoBlend, audioBalance, isExclusive);

    switch (sourceFormat) {
        case AUDIO_FORMAT_PCM_FLOAT:
@@ -94,6 +95,8 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat,
        return AAUDIO_ERROR_UNIMPLEMENTED;
    }

    // Apply volume ramps for only exclusive streams.
    if (isExclusive) {
        // Apply volume ramps to set the left/right audio balance and target volumes.
        // The signals will be decoupled, volume ramps will be applied, before the signals are
        // combined again.
@@ -110,6 +113,7 @@ aaudio_result_t AAudioFlowGraph::configure(audio_format_t sourceFormat,
        }
        lastOutput = &mManyToMultiConverter->output;
        setAudioBalance(audioBalance);
    }

    switch (sinkFormat) {
        case AUDIO_FORMAT_PCM_FLOAT:
+3 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ public:
     * @param useMonoBlend
     * @param audioBalance
     * @param channelMask
     * @param isExclusive
     * @return
     */
    aaudio_result_t configure(audio_format_t sourceFormat,
@@ -50,7 +51,8 @@ public:
                              audio_format_t sinkFormat,
                              int32_t sinkChannelCount,
                              bool useMonoBlend,
                              float audioBalance);
                              float audioBalance,
                              bool isExclusive);

    void process(const void *source, void *destination, int32_t numFrames);

+2 −1
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ aaudio_result_t AudioStreamInternalPlay::open(const AudioStreamBuilder &builder)
                             getDeviceFormat(),
                             getDeviceChannelCount(),
                             getRequireMonoBlend(),
                             getAudioBalance());
                             getAudioBalance(),
                             (getSharingMode() == AAUDIO_SHARING_MODE_EXCLUSIVE));

        if (result != AAUDIO_OK) {
            safeReleaseClose();