summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2013-05-02 17:27:25 -0500
committerRanganath Krishnan <ranganath@ti.com>2013-05-08 10:21:48 -0500
commit0bfa06521cb65e0354bde062fb110e06acf728ab (patch)
treee4727d9ab53011a5cee626e8a43a9b9b9cdc13d3
parente7dcaf0d0b9f3c41521adec5fb37b01524fe5419 (diff)
downloadcommon-open-0bfa06521cb65e0354bde062fb110e06acf728ab.tar.gz
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,
if (!out->up) {
if(hdmi_out_open_pcm(out)) {
- return -ENOSYS;
+ ret = -ENOSYS;
+ goto exit;
}
}
@@ -382,15 +383,20 @@ ssize_t hdmi_out_write(struct audio_stream_out *stream, const void* buffer,
} else {
ret = pcm_write(out->pcm, buffer, bytes);
}
- if (ret) {
+exit:
+ if (ret != 0) {
ALOGE("Error writing to HDMI pcm: %s", pcm_get_error(out->pcm));
- ret = (ret < 0) ? ret : -ret;
hdmi_out_standby((struct audio_stream*)stream);
- } else {
- ret = bytes;
+ unsigned int usecs = bytes * 1000000 /
+ audio_stream_frame_size((struct audio_stream*)stream) /
+ hdmi_out_get_sample_rate((struct audio_stream*)stream);
+ if (usecs >= 1000000L) {
+ usecs = 999999L;
+ }
+ usleep(usecs);
}
- return ret;
+ return bytes;
}