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

Commit dbd20561 authored by Mingshu Pang's avatar Mingshu Pang Committed by Gerrit - the friendly Code Review server
Browse files

hal: reset default parameters when ignoring non-existing USB sound card

Reset default parameter when ignoring non-existing USB sound card to
avoid crash when plugging in/out USB quickly.

CRs-fixed: 2570460
Change-Id: I4bbe3d3e1f4afc54fb4d637b9e6156a7534cd1bc
parent 7098e119
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -7460,6 +7460,12 @@ int adev_open_output_stream(struct audio_hw_device *dev,
        devices = AUDIO_DEVICE_OUT_SPEAKER;
        ALOGW("%s: ignore set device to non existing USB card, use output device(%#x)",
              __func__, devices);
        if (config->format == AUDIO_FORMAT_DEFAULT)
            config->format = AUDIO_FORMAT_PCM_16_BIT;
        if (config->sample_rate == 0)
            config->sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
        if (config->channel_mask == AUDIO_CHANNEL_NONE)
            config->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
    }

    *stream_out = NULL;