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

Commit 4515129c authored by Phil Burk's avatar Phil Burk
Browse files

audiopolicy: use an exact match for MMAP input

AudioFlinger was returning a stereo input if mono was requested
but not supported.
But AAudio did not know it was stereo so the data was corrupted.
So if MMAP input is requested, do an exact match in
isCompatibleProfile().

Bug: 119518992
Test: see bug for repo steps
Test: adb shell aaudio_loopback -tm -pl -Pl -x -X -C1
Change-Id: I925efecca9c99b8a2b7bde3826da4d9e9e663ee1
parent eb8b659a
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "APM::IOProfile"
//#define LOG_NDEBUG 0

#include <system/audio-base.h>
#include "IOProfile.h"
#include "HwModule.h"
#include "AudioGain.h"
@@ -66,19 +67,23 @@ bool IOProfile::isCompatibleProfile(audio_devices_t device,
    audio_format_t myUpdatedFormat = format;
    audio_channel_mask_t myUpdatedChannelMask = channelMask;
    uint32_t myUpdatedSamplingRate = samplingRate;
    if (isRecordThread)
    {
        if (checkCompatibleAudioProfile(
                myUpdatedSamplingRate, myUpdatedChannelMask, myUpdatedFormat) != NO_ERROR) {
            return false;
        }
    } else {
    const struct audio_port_config config = {
        .config_mask = AUDIO_PORT_CONFIG_ALL & ~AUDIO_PORT_CONFIG_GAIN,
        .sample_rate = samplingRate,
        .channel_mask = channelMask,
        .format = format,
    };
    if (isRecordThread)
    {
        if ((flags & AUDIO_INPUT_FLAG_MMAP_NOIRQ) != 0) {
            if (checkExactAudioProfile(&config) != NO_ERROR) {
                return false;
            }
        } else if (checkCompatibleAudioProfile(
                myUpdatedSamplingRate, myUpdatedChannelMask, myUpdatedFormat) != NO_ERROR) {
            return false;
        }
    } else {
        if (checkExactAudioProfile(&config) != NO_ERROR) {
            return false;
        }