hal: In case of error in in_read don't return zero
When read fails HAL is returning bytes_read as zero, this
is causing recordThread forever looping in threadLoop, leading
ANR in cases like in-call record + SubSystemRestart.
Make sure HAL returns 'size', AudioFlinger is reading data of.
CRs-Fixed: 2021657
Change-Id: Ie4c07c6a888c1ec66ed032b0d2912633cf15368c
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 6644b48..1b0e1f1 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3794,7 +3794,10 @@
pthread_mutex_unlock(&adev->lock);
in->standby = true;
}
- memset(buffer, 0, bytes);
+ if (!audio_extn_cin_attached_usecase(in->usecase)) {
+ bytes_read = bytes;
+ memset(buffer, 0, bytes);
+ }
in_standby(&in->stream.common);
ALOGV("%s: read failed status %d- sleeping for buffer duration", __func__, ret);
usleep((uint64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) /