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

Commit 8ae73129 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: fix call audio over 24 bit USB device

Take into account voice RX source device properties when
configuring the audio patch bridging the voice RX device
to the USB output device.

Bug: 25643110

Change-Id: I06f282d3cc12493f21500bf9ab35a3ceb93f14af
parent aff4e460
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -248,14 +248,27 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
                        goto exit;
                    }
                }
                uint32_t channelCount = newPatch->mPlaybackThread->channelCount();
                audio_devices_t device = patch->sources[0].ext.device.type;
                String8 address = String8(patch->sources[0].ext.device.address);
                audio_config_t config = AUDIO_CONFIG_INITIALIZER;
                audio_channel_mask_t inChannelMask = audio_channel_in_mask_from_count(channelCount);
                // open input stream with source device audio properties if provided or
                // default to peer output stream properties otherwise.
                if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) {
                    config.sample_rate = patch->sources[0].sample_rate;
                } else {
                    config.sample_rate = newPatch->mPlaybackThread->sampleRate();
                config.channel_mask = inChannelMask;
                }
                if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
                    config.channel_mask = patch->sources[0].channel_mask;
                } else {
                    config.channel_mask =
                        audio_channel_in_mask_from_count(newPatch->mPlaybackThread->channelCount());
                }
                if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_FORMAT) {
                    config.format = patch->sources[0].format;
                } else {
                    config.format = newPatch->mPlaybackThread->format();
                }
                audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
                newPatch->mRecordThread = audioflinger->openInput_l(srcModule,
                                                                    &input,
@@ -265,7 +278,7 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
                                                                    AUDIO_SOURCE_MIC,
                                                                    AUDIO_INPUT_FLAG_NONE);
                ALOGV("audioflinger->openInput_l() returned %p inChannelMask %08x",
                      newPatch->mRecordThread.get(), inChannelMask);
                      newPatch->mRecordThread.get(), config.channel_mask);
                if (newPatch->mRecordThread == 0) {
                    status = NO_MEMORY;
                    goto exit;
+11 −1
Original line number Diff line number Diff line
@@ -228,7 +228,17 @@ audio_policy_dev_state_t DeviceVector::getDeviceConnectionState(const sp<DeviceD
void DeviceDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig,
                                         const struct audio_port_config *srcConfig) const
{
    dstConfig->config_mask = AUDIO_PORT_CONFIG_CHANNEL_MASK|AUDIO_PORT_CONFIG_GAIN;
    dstConfig->config_mask = AUDIO_PORT_CONFIG_GAIN;
    if (mSamplingRate != 0) {
        dstConfig->config_mask |= AUDIO_PORT_CONFIG_SAMPLE_RATE;
    }
    if (mChannelMask != AUDIO_CHANNEL_NONE) {
        dstConfig->config_mask |= AUDIO_PORT_CONFIG_CHANNEL_MASK;
    }
    if (mFormat != AUDIO_FORMAT_INVALID) {
        dstConfig->config_mask |= AUDIO_PORT_CONFIG_FORMAT;
    }

    if (srcConfig != NULL) {
        dstConfig->config_mask |= srcConfig->config_mask;
    }
+7 −7
Original line number Diff line number Diff line
@@ -309,9 +309,6 @@ audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devi
void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs)
{
    bool createTxPatch = false;
    struct audio_patch patch;
    patch.num_sources = 1;
    patch.num_sinks = 1;
    status_t status;
    audio_patch_handle_t afPatchHandle;
    DeviceVector deviceList;
@@ -344,8 +341,11 @@ void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs
                == AUDIO_DEVICE_NONE) {
            createTxPatch = true;
        }
    } else {
        // create RX path audio patch
    } else { // create RX path audio patch
        struct audio_patch patch;

        patch.num_sources = 1;
        patch.num_sinks = 1;
        deviceList = mAvailableOutputDevices.getDevicesFromType(rxDevice);
        ALOG_ASSERT(!deviceList.isEmpty(),
                    "updateCallRouting() selected device not in output device list");
@@ -384,9 +384,9 @@ void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs
        }
        createTxPatch = true;
    }
    if (createTxPatch) {

    if (createTxPatch) { // create TX path audio patch
        struct audio_patch patch;

        patch.num_sources = 1;
        patch.num_sinks = 1;
        deviceList = mAvailableInputDevices.getDevicesFromType(txDevice);