hal: Resolves rewound and restart issue during SSR/PDR.

Audio playback after SSR/PDR gets rewound or restarts.

The issue occurs because of two scenarios:

1.out_get_render_position returns 0 when card status goes from offline
to online and out->compr is NULL.So,getPosition returns default 0 dsp
frames and anchorTime gets updated to mAudioFirstAnchorTimeMediaUs,
making it seek to the wrong position.

2.out_get_presentation_position returns 0 when out->compr is NULL,
even for offload usecase.

To solve the first issue introduce a flag which is true if the card
was offline previously and out_get_render_position checks the flag,
which if true return invalid value.For the second issue return failure
from out_get_presentation_position when out->compr is NULL and it is
offload usecase.

CRs-Fixed: 2392929
Change-Id: Ic0718bc2d62e4b05a6166efeb33ccf658d6cad2d
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index b0f7efd..ba25969 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3724,6 +3724,12 @@
     if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
         send_offload_cmd_l(out, OFFLOAD_CMD_ERROR);
     }
+
+    if (is_offload_usecase(out->usecase) && out->card_status == CARD_STATUS_OFFLINE) {
+        ALOGD("Setting previous card status if offline");
+        out->prev_card_status_offline = true;
+    }
+
     pthread_mutex_unlock(&out->lock);
 
     return status;
@@ -4947,6 +4953,9 @@
              */
             ALOGE(" ERROR: sound card not active, return error");
             ret = -EINVAL;
+        } else if (out->prev_card_status_offline) {
+            ALOGE("ERROR: previously sound card was offline,return error");
+            ret = -EINVAL;
         } else {
             ret = 0;
             adjust_frames_for_device_delay(out, dsp_frames);
@@ -5049,7 +5058,10 @@
         } else if (out->card_status == CARD_STATUS_OFFLINE) {
             *frames = out->written;
             clock_gettime(CLOCK_MONOTONIC, timestamp);
-            ret = 0;
+            if (is_offload_usecase(out->usecase))
+                ret = -EINVAL;
+            else
+                ret = 0;
         }
     }
     pthread_mutex_unlock(&out->lock);
@@ -6092,6 +6104,7 @@
     out->hal_output_suspend_supported = 0;
     out->dynamic_pm_qos_config_supported = 0;
     out->set_dual_mono = false;
+    out->prev_card_status_offline = false;
 
     if ((flags & AUDIO_OUTPUT_FLAG_BD) &&
         (property_get_bool("vendor.audio.matrix.limiter.enable", false)))
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 1675893..003690a 100755
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -355,6 +355,7 @@
     mix_matrix_params_t pan_scale_params;
     mix_matrix_params_t downmix_params;
     bool set_dual_mono;
+    bool prev_card_status_offline;
 };
 
 struct stream_in {