hal: Allow only 48k, 96k, or 192k for TrueHD playback

TrueHD for compressed pass-through is only supported
for sample rates of 48k, 96, or 192k. Return an error
code for any other requested sample rates.

Change-Id: I9b917cee31f907fddbaa5ea755aad491ae55e3fc
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 2228106..3edc1c0 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -4300,6 +4300,18 @@
             goto error_open;
         }
 
+        /* TrueHD only supported for 48k multiples (48k, 96k, 192k) */
+        if ((config->offload_info.format == AUDIO_FORMAT_DOLBY_TRUEHD) &&
+                (audio_extn_passthru_is_passthrough_stream(out)) &&
+                !((config->sample_rate == 48000) ||
+                  (config->sample_rate == 96000) ||
+                  (config->sample_rate == 192000))) {
+            ALOGE("%s: Unsupported sample rate %d for audio format %x",
+                    __func__, config->sample_rate, config->offload_info.format);
+            ret = -EINVAL;
+            goto error_open;
+        }
+
         out->compr_config.codec = (struct snd_codec *)
                                     calloc(1, sizeof(struct snd_codec));