diff options
author | Misael Lopez Cruz | 2013-05-02 17:27:25 -0500 |
---|---|---|
committer | Ranganath Krishnan | 2013-05-02 17:34:06 -0500 |
commit | 159888db12a922d6374e76d6ca4a9f3267c0b98e (patch) | |
tree | e4727d9ab53011a5cee626e8a43a9b9b9cdc13d3 | |
parent | e7dcaf0d0b9f3c41521adec5fb37b01524fe5419 (diff) | |
download | device-ti-common-open-159888db12a922d6374e76d6ca4a9f3267c0b98e.tar.gz device-ti-common-open-159888db12a922d6374e76d6ca4a9f3267c0b98e.tar.xz device-ti-common-open-159888db12a922d6374e76d6ca4a9f3267c0b98e.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.c | 18 |
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) { | 386 | exit: |
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 | ||