From 188dea8e6877451336012704147ce5d01654ee81 Mon Sep 17 00:00:00 2001 From: deadwood Date: Sat, 10 Oct 2015 19:35:09 +0000 Subject: [PATCH] alsa.audio: move handling of XRUN when writting to the slave task git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@51143 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/devs/AHI/Drivers/Alsa/alsa-bridge/alsa.c | 5 +---- workbench/devs/AHI/Drivers/Alsa/alsa-playslave.c | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/workbench/devs/AHI/Drivers/Alsa/alsa-bridge/alsa.c b/workbench/devs/AHI/Drivers/Alsa/alsa-bridge/alsa.c index cdaa743279..39e739fe26 100644 --- a/workbench/devs/AHI/Drivers/Alsa/alsa-bridge/alsa.c +++ b/workbench/devs/AHI/Drivers/Alsa/alsa-bridge/alsa.c @@ -62,10 +62,7 @@ LONG ALSA_Write(APTR handle, APTR buffer, ULONG size) LONG rc = ALSACALL(snd_pcm_writei, handle, buffer, (snd_pcm_uframes_t)size); if (rc == -EPIPE) - { - ALSACALL(snd_pcm_prepare, handle); - rc = ALSACALL(snd_pcm_writei, handle, buffer, (snd_pcm_uframes_t)size); - } + rc = ALSA_XRUN; return rc; } diff --git a/workbench/devs/AHI/Drivers/Alsa/alsa-playslave.c b/workbench/devs/AHI/Drivers/Alsa/alsa-playslave.c index f040c1e63f..d36eb03ad8 100644 --- a/workbench/devs/AHI/Drivers/Alsa/alsa-playslave.c +++ b/workbench/devs/AHI/Drivers/Alsa/alsa-playslave.c @@ -103,7 +103,14 @@ Slave( struct ExecBase* SysBase ) framesptr = dd->mixbuffer; } - written = ALSA_Write(dd->alsahandle, framesptr, min(framesready, framesfree)); + written = ALSA_Write(dd->alsahandle, framesptr, min(framesready, + framesfree)); + if (written == ALSA_XRUN) + { + ALSA_Prepare(dd->alsahandle); + written = ALSA_Write(dd->alsahandle, framesptr, min(framesready, + framesfree)); + } framesready -= written; framesfree -= written; -- 2.11.4.GIT