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
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 8f18c8f..9f20953 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -7460,6 +7460,12 @@
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;