hal: Fix audioserver crash in device switch

Audioserver crashes at times when performing
a device switch. This is because memory
associated with offload callback thread
was being freed even though the thread
was still active. Fix this by making sure
that the thread is created only if the thread
is necessary

Change-Id: Ib9230d23004d9c8756d7688846d46e14ea219453
CRs-Fixed: 1061896
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 43c83de..1215d2d 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3754,7 +3754,6 @@
 
         audio_extn_dts_create_state_notifier_node(out->usecase);
 
-        create_offload_callback_thread(out);
         ALOGV("%s: offloaded output offload_info version %04x bit rate %d",
                 __func__, config->offload_info.version,
                 config->offload_info.bit_rate);
@@ -3790,6 +3789,9 @@
             out->flags |= AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH;
             out->compr_config.codec->compr_passthr = PASSTHROUGH_DSD;
         }
+
+        create_offload_callback_thread(out);
+
     } else if (out->flags & AUDIO_OUTPUT_FLAG_INCALL_MUSIC) {
         ret = voice_extn_check_and_set_incall_music_usecase(adev, out);
         if (ret != 0) {