hal: Fix DSP crash when passthru session is opened for unsupported channels
- DSP crash is seen when device channel configuration is less than
stream channels for passthrough usecases.
- Return error when stream channels are more than max supported
channels by the sink during compress passthrough playback
Change-Id: Icb8f2fd23880be57b3befe4a2a75a19c8ca5acfa
CRs-fixed: 2096943
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 926a63f..4b04f0b 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3708,6 +3708,7 @@
struct stream_out *out = (struct stream_out *)stream;
struct audio_device *adev = out->dev;
ssize_t ret = 0;
+ int channels = 0;
lock_output_stream(out);
@@ -3737,6 +3738,7 @@
}
if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
+ channels = platform_edid_get_max_channels(out->dev->platform);
if (audio_extn_passthru_is_enabled() &&
!out->is_iec61937_info_available &&
audio_extn_passthru_is_passthrough_stream(out)) {
@@ -3766,6 +3768,14 @@
out->is_iec61937_info_available = true;
}
}
+
+ if ((channels < audio_channel_count_from_out_mask(out->channel_mask)) &&
+ (out->compr_config.codec->compr_passthr == PASSTHROUGH) &&
+ (out->is_iec61937_info_available == true)) {
+ ALOGE("%s: ERROR: Unsupported channel config in passthrough mode", __func__);
+ ret = -EINVAL;
+ goto exit;
+ }
}
}