summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2013-05-02 17:27:25 -0500
committerRanganath Krishnan2013-05-08 10:21:48 -0500
commit0bfa06521cb65e0354bde062fb110e06acf728ab (patch)
treee4727d9ab53011a5cee626e8a43a9b9b9cdc13d3
parente7dcaf0d0b9f3c41521adec5fb37b01524fe5419 (diff)
downloaddevice-ti-common-open-0bfa06521cb65e0354bde062fb110e06acf728ab.tar.gz
device-ti-common-open-0bfa06521cb65e0354bde062fb110e06acf728ab.tar.xz
device-ti-common-open-0bfa06521cb65e0354bde062fb110e06acf728ab.zip
audio: hdmi: Handle error writing to device in hdmi_out_write()
If there is an error writing to the device in hdmi_out_write(), the function then sleeps for the size of the current fragment (bytes arg, converted to seconds). Change-Id: I2ea3942a02e14ea00c73a8519839865aab59ae00 Signed-off-by: Ranganath Krishnan <ranganath@ti.com> Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r--audio/hdmi_audio_hw.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/audio/hdmi_audio_hw.c b/audio/hdmi_audio_hw.c
index f46aee6..cd44aec 100644
--- a/audio/hdmi_audio_hw.c
+++ b/audio/hdmi_audio_hw.c
@@ -372,7 +372,8 @@ ssize_t hdmi_out_write(struct audio_stream_out *stream, const void* buffer,
372 372
373 if (!out->up) { 373 if (!out->up) {
374 if(hdmi_out_open_pcm(out)) { 374 if(hdmi_out_open_pcm(out)) {
375 return -ENOSYS; 375 ret = -ENOSYS;
376 goto exit;
376 } 377 }
377 } 378 }
378 379
@@ -382,15 +383,20 @@ ssize_t hdmi_out_write(struct audio_stream_out *stream, const void* buffer,
382 } else { 383 } else {
383 ret = pcm_write(out->pcm, buffer, bytes); 384 ret = pcm_write(out->pcm, buffer, bytes);
384 } 385 }
385 if (ret) { 386exit:
387 if (ret != 0) {
386 ALOGE("Error writing to HDMI pcm: %s", pcm_get_error(out->pcm)); 388 ALOGE("Error writing to HDMI pcm: %s", pcm_get_error(out->pcm));
387 ret = (ret < 0) ? ret : -ret;
388 hdmi_out_standby((struct audio_stream*)stream); 389 hdmi_out_standby((struct audio_stream*)stream);
389 } else { 390 unsigned int usecs = bytes * 1000000 /
390 ret = bytes; 391 audio_stream_frame_size((struct audio_stream*)stream) /
392 hdmi_out_get_sample_rate((struct audio_stream*)stream);
393 if (usecs >= 1000000L) {
394 usecs = 999999L;
395 }
396 usleep(usecs);
391 } 397 }
392 398
393 return ret; 399 return bytes;
394} 400}
395 401
396 402