hal: return error if write fails
An error code is returned if there is any failure in
out_write() API in the case of passthrough streams.
This change is needed to handle the error scenarios
properly in the application.
Change-Id: I760cb9342291490f0bf1fb61e196d57558c09fb5
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c0e28c6..2524448 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3944,6 +3944,11 @@
if (!(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD))
usleep((uint64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) /
out_get_sample_rate(&out->stream.common));
+
+ if (audio_extn_passthru_is_passthrough_stream(out)) {
+ ALOGE("%s: write error, ret = %d", __func__, ret);
+ return ret;
+ }
}
return bytes;
}
diff --git a/qahw_api/test/qahw_playback_test.c b/qahw_api/test/qahw_playback_test.c
index a069629..91995f6 100644
--- a/qahw_api/test/qahw_playback_test.c
+++ b/qahw_api/test/qahw_playback_test.c
@@ -563,7 +563,7 @@
size_t bytes_wanted = 0;
size_t write_length = 0;
size_t bytes_remaining = 0;
- size_t bytes_written = 0;
+ ssize_t bytes_written = 0;
size_t bytes_read = 0;
char *data_ptr = NULL;