Audio: Fix for sound card status overwrite issue

 - Sound card status is getting over written to OFFLINE
   by HAL internally on continuous SSR
 - Fix by returning different error code for snd card offline
   update in HAL internally instead of ENETRESET

Change-Id: I98a34d8b667dff045a1e99d18307376579ac4ebc
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 05ad4f6..69f3b20 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -850,7 +850,7 @@
 
     if (SND_CARD_STATE_OFFLINE == snd_card_status) {
         ALOGE("%s: sound card is not active/SSR returning error", __func__);
-        ret = -ENETRESET;
+        ret = -EIO;
         goto error_config;
     }
 
@@ -1254,7 +1254,7 @@
 
     if (SND_CARD_STATE_OFFLINE == snd_card_status) {
         ALOGE("%s: sound card is not active/SSR returning error", __func__);
-        ret = -ENETRESET;
+        ret = -EIO;
         goto error_config;
     }
 
@@ -1774,7 +1774,7 @@
     if (SND_CARD_STATE_OFFLINE == snd_scard_state) {
         if (out->pcm) {
             ALOGD(" %s: sound card is not active/SSR state", __func__);
-            ret= -ENETRESET;
+            ret= -EIO;
             goto exit;
         } else if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
             //during SSR for compress usecase we should return error to flinger
@@ -2229,7 +2229,7 @@
     if (in->pcm) {
         if(SND_CARD_STATE_OFFLINE == snd_scard_state) {
             ALOGD(" %s: sound card is not active/SSR state", __func__);
-            ret= -ENETRESET;
+            ret= -EIO;;
             goto exit;
         }
     }
@@ -2267,10 +2267,9 @@
 
 exit:
     /* ToDo: There may be a corner case when SSR happens back to back during
-        start/stop. Need to post different error to handle that. */
+       start/stop. Need to post different error to handle that. */
     if (-ENETRESET == ret) {
         set_snd_card_state(adev,SND_CARD_STATE_OFFLINE);
-        memset(buffer, 0, bytes);
     }
     pthread_mutex_unlock(&in->lock);
 
@@ -2281,6 +2280,7 @@
             pthread_mutex_unlock(&adev->lock);
             in->standby = true;
         }
+        memset(buffer, 0, bytes);
         in_standby(&in->stream.common);
         ALOGV("%s: read failed - sleeping for buffer duration", __func__);
         usleep(bytes * 1000000 / audio_stream_frame_size(&in->stream.common) /