From 7b027ee36f0e7850820b1e9cc0214c69688c6917 Mon Sep 17 00:00:00 2001
From: Hans de Goede <j.w.r.degoede@hhs.nl>
Date: Mon, 11 May 2009 16:53:23 +0200
Subject: [PATCH 9/9] alsa output plugin: use snd_pcm_recover()
The alsa_recovery() function this patch removes does exactly the same as
the alsa-lib snd_pcm_recover() function, so use that instead.
---
src/alsa/audio.c | 57 +----------------------------------------------------
1 files changed, 2 insertions(+), 55 deletions(-)
diff --git a/src/alsa/audio.c b/src/alsa/audio.c
index ca9c70d..ed3af92 100644
--- a/src/alsa/audio.c
+++ b/src/alsa/audio.c
@@ -147,59 +147,6 @@ int alsa_playing(void)
return ret;
}
-static int
-alsa_recovery(int err)
-{
- int err2;
-
- /* if debug mode is enabled, dump ALSA state to console */
- if (alsa_cfg.debug)
- {
- snd_pcm_status_t *alsa_status = NULL;
- snd_pcm_status_alloca(&alsa_status);
- if (snd_pcm_status(alsa_pcm, alsa_status) < 0)
- g_warning("xrun_recover(): snd_pcm_status() failed");
- else
- {
- printf("Status:\n");
- snd_pcm_status_dump(alsa_status, logs);
- }
- }
-
- /*
- * specifically handle -EPIPE and -ESTRPIPE to recover
- * PCM fragment periods without losing data.
- */
- switch (err)
- {
- case -ESTRPIPE:
- case ESTRPIPE: /* "suspend": wait until ALSA is "running" again. */
- while ((err2 = snd_pcm_resume(alsa_pcm)) == -EAGAIN)
- g_usleep(100000);
-
- if (err2 < 0)
- return snd_pcm_prepare(alsa_pcm);
-
- break;
-
- case -EPIPE:
- case EPIPE: /* under-run and the I/O pipe closed on us */
- return snd_pcm_prepare(alsa_pcm);
- break;
-
- case EINTR:
- case -EINTR:
- break;
-
- default:
- g_warning("Unhandled ALSA exception code %d (%s), trying hard restart.", err, snd_strerror(err));
- return snd_pcm_prepare(alsa_pcm);
- break;
- }
-
- return 0;
-}
-
/* update and get the available space on h/w buffer (in frames) */
static snd_pcm_sframes_t alsa_get_avail(void)
{
@@ -210,7 +157,7 @@ static snd_pcm_sframes_t alsa_get_avail(void)
while ((ret = snd_pcm_avail_update(alsa_pcm)) < 0)
{
- ret = alsa_recovery(ret);
+ ret = snd_pcm_recover(alsa_pcm, ret, !alsa_cfg.debug);
if (ret < 0)
{
g_warning("alsa_get_avail(): snd_pcm_avail_update() failed: %s",
@@ -659,7 +606,7 @@ static void alsa_write_audio(char *data, int length)
}
else
{
- int err = alsa_recovery((int)written_frames);
+ int err = snd_pcm_recover(alsa_pcm, written_frames, !alsa_cfg.debug);
if (err < 0)
{
g_warning("alsa_write_audio(): write error: %s",
--
1.6.2.2