hal: Configure correct COPP sample rate for USB and HDMI devices.
-In case of playback over HDMI/USB, the device might not support
the same sample rate as of the stream, though it is preferred that
resampling happens after post processing, but if device sample rate
is not even a multiple of stream sample rate, ensure that resampling
happens in the COPP.
Change-Id: Ia8cdff5294433ec099b703001d11da905bf82c9b
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 9542fbd..eb3213c 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -666,6 +666,18 @@
if ((24 == usecase->stream.out->bit_width) &&
(usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+ } else if ((snd_device == SND_DEVICE_OUT_HDMI ||
+ snd_device == SND_DEVICE_OUT_USB_HEADSET ||
+ snd_device == SND_DEVICE_OUT_DISPLAY_PORT) &&
+ (usecase->stream.out->sample_rate >= OUTPUT_SAMPLING_RATE_44100)) {
+ /*
+ * To best utlize DSP, check if the stream sample rate is supported/multiple of
+ * configured device sample rate, if not update the COPP rate to be equal to the
+ * device sample rate, else open COPP at stream sample rate
+ */
+ platform_check_and_update_copp_sample_rate(adev->platform, snd_device,
+ usecase->stream.out->sample_rate,
+ &usecase->stream.out->app_type_cfg.sample_rate);
} else if ((snd_device != SND_DEVICE_OUT_HEADPHONES_44_1 &&
usecase->stream.out->sample_rate == OUTPUT_SAMPLING_RATE_44100) ||
(usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) {