audio: Fix for clip skip issue during SSR

- Specific AAC clips are skipped to next clip on triggering SSR
- When SSR is triggered while track is waiting for stream end event for
  low bit rate clips, drain is unblocked and playback is switched to
  next track
- Fix is not to post drain ready event during SSR as actual stream end
  is not reached with more compressed data buffered to DSP

  CRs-Fixed: 766541

Change-Id: Id1573160001a2a252dc6613b58f70233e77cc3b4
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index b933af8..f5c182a 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1172,15 +1172,22 @@
             ret = compress_next_track(out->compr);
             if(ret == 0) {
                 ALOGD("copl(%p):calling compress_partial_drain", out);
-                compress_partial_drain(out->compr);
+                ret = compress_partial_drain(out->compr);
                 ALOGD("copl(%p):out of compress_partial_drain", out);
+                if (ret < 0)
+                    ret = -errno;
             }
-            else if(ret == -ETIMEDOUT)
+            else if (ret == -ETIMEDOUT)
                 compress_drain(out->compr);
             else
                 ALOGE("%s: Next track returned error %d",__func__, ret);
-            send_callback = true;
-            event = STREAM_CBK_EVENT_DRAIN_READY;
+
+            if (ret != -ENETRESET) {
+                send_callback = true;
+                event = STREAM_CBK_EVENT_DRAIN_READY;
+                ALOGV("copl(%p):send drain callback, ret %d", out, ret);
+            } else
+                ALOGE("%s: Block drain ready event during SSR", __func__);
             break;
         case OFFLOAD_CMD_DRAIN:
             ALOGD("copl(%p):calling compress_drain", out);