hal: fix missing calibration issue for playback on speaker

- ADM calibration is sometimes not sent for playback on speaker
  due to use of unsupported sample rate by send calibration routine.
- Fix the issue by updating app_type sample_rate for output
  to supported value before sending calibration data.

Change-Id: I3a04b6b7dd26aa53c1726d6a9a8e3cb72f7ba74e
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index b9e2a40..a39c8aa 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -566,14 +566,13 @@
     } else if (usecase->type == PCM_PLAYBACK) {
         if ((24 == usecase->stream.out->bit_width) &&
             (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
-            sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+            usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_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)) {
-            sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
-        } else {
-            sample_rate = usecase->stream.out->app_type_cfg.sample_rate;
+            usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
         }
+        sample_rate = usecase->stream.out->app_type_cfg.sample_rate;
 
         app_type_cfg[len++] = usecase->stream.out->app_type_cfg.app_type;
         app_type_cfg[len++] = acdb_dev_id;
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index d5db25b..1c11484 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -453,8 +453,8 @@
     audio_extn_dolby_ds2_set_endpoint(adev);
     audio_extn_sound_trigger_update_stream_status(usecase, ST_EVENT_STREAM_BUSY);
     audio_extn_listen_update_stream_status(usecase, LISTEN_EVENT_STREAM_BUSY);
-    audio_extn_utils_send_audio_calibration(adev, usecase);
     audio_extn_utils_send_app_type_cfg(adev, usecase);
+    audio_extn_utils_send_audio_calibration(adev, usecase);
     strcpy(mixer_path, use_case_table[usecase->id]);
     platform_add_backend_name(mixer_path, snd_device, usecase);
     ALOGD("%s: apply mixer and update path: %s", __func__, mixer_path);