From 325c49cf90cb8d35fe5766fe9b6a4b7581411c91 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Wed, 25 Jan 2006 17:40:59 +0000 Subject: * Patch from SuSE to fix alsa after hardware suspend * Fix the ./configure --enable-static-xv parameter CVS patchset: 7844 CVS date: 2006/01/25 17:40:59 --- ChangeLog | 2 ++ configure.ac | 12 ++++++++---- src/audio_out/audio_alsa_out.c | 27 ++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64bc30ed6..69a511ca9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ xine-lib (1.1.2) * Fix using xine-lib on systems with SELinux enabled * Build right with libiconv in /usr/local as default on FreeBSD * Fix a potential crash with fixed-size lacing in the Matroska demuxer + * Patch from SuSE to fix alsa after hardware suspend + * Fix the ./configure --enable-static-xv parameter xine-lib (1.1.1) * Improve sound quality when using alsa 1.0.9 or above. diff --git a/configure.ac b/configure.ac index 3da2f2f2b..ccdae89ef 100644 --- a/configure.ac +++ b/configure.ac @@ -571,10 +571,14 @@ dnl Only dynamic linking is possible when using libtool < 1.4.0 AC_ARG_WITH(xv-path, AC_HELP_STRING([--with-xv-path=path], [where libXv is installed]), xv_path="$withval",) -AC_ARG_ENABLE(shared-xv, - AC_HELP_STRING([--enable-static-xv],[Enable this to force linking against libXv.a]), - xv_prefer_shared="no", - xv_prefer_shared="yes") +AC_ARG_ENABLE([static-xv], + AC_HELP_STRING([--enable-static-xv],[Enable this to force linking against libXv.a])) + +if test "x$enable_static_xv" = "xyes"; then + xv_prefer_shared="no" +else + xv_prefer_shared="yes" +fi if test x"$no_x" != "xyes"; then AC_FIND_LIBXV diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 9f188222c..c0a9e9ba0 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton * * - * $Id: audio_alsa_out.c,v 1.156 2005/09/24 19:27:33 miguelfreitas Exp $ + * $Id: audio_alsa_out.c,v 1.157 2006/01/25 17:40:59 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -718,6 +718,19 @@ static void xrun(alsa_driver_t *this) } #endif +/* + * resume from suspend + */ +static int resume(snd_pcm_t *pcm) +{ + int res; + while ((res = snd_pcm_resume(pcm)) == -EAGAIN) + sleep(1); + if (! res) + return 0; + return snd_pcm_prepare(pcm); +} + /* * Write audio data to output buffer (blocking using snd_pcm_wait) */ @@ -742,6 +755,12 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) { #endif snd_pcm_status_alloca(&pcm_stat); state = snd_pcm_state(this->audio_fd); + if (state == SND_PCM_STATE_SUSPENDED) { + res = resume(this->audio_fd); + if (res < 0) + return 0; + state = snd_pcm_state(this->audio_fd); + } if (state == SND_PCM_STATE_XRUN) { #ifdef LOG_DEBUG printf("audio_alsa_out:write:XRUN before\n"); @@ -791,6 +810,12 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) { printf("audio_alsa_out:write:result=%ld:%s\n",result, snd_strerror(result)); #endif state = snd_pcm_state(this->audio_fd); + if (state == SND_PCM_STATE_SUSPENDED) { + res = resume(this->audio_fd); + if (res < 0) + return 0; + continue; + } if ( (state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING) && (state != SND_PCM_STATE_DRAINING) ) { -- cgit v1.2.3