qahw: Add condition to check bytes written to hal
A2dp source playback is not stopped even bytes written is < 0.
Add condition to check bytes written and exit playback if
bytes written is < 0.
Change-Id: I0c4c67434df8c2aae701ed8ada16cc22dd690430
diff --git a/qahw_api/test/qahw_playback_test.c b/qahw_api/test/qahw_playback_test.c
index 1f65368..0265178 100644
--- a/qahw_api/test/qahw_playback_test.c
+++ b/qahw_api/test/qahw_playback_test.c
@@ -373,7 +373,7 @@
qahw_in_buffer_t in_buf;
char *buffer;
int rc = 0;
- int bytes_to_read, bytes_written = 0;
+ int bytes_to_read, bytes_written = 0, bytes_wrote = 0;
FILE *fp = NULL;
qahw_stream_handle_t* in_handle = nullptr;
@@ -415,7 +415,13 @@
while (!(params->acp.thread_exit)) {
rc = qahw_in_read(in_handle, &in_buf);
if (rc > 0) {
- bytes_written += fwrite((char *)(in_buf.buffer), sizeof(char), (int)in_buf.bytes, fp);
+ bytes_wrote = fwrite((char *)(in_buf.buffer), sizeof(char), (int)in_buf.bytes, fp);
+ bytes_written += bytes_wrote;
+ if(bytes_wrote < in_buf.bytes) {
+ stop_playback = true;
+ fprintf(log_file, "Error in fwrite due to no memory(%d)=%s\n",ferror(fp), strerror(ferror(fp)));
+ break;
+ }
}
}
params->hdr.data_sz = bytes_written;