Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MW6kj-0002mc-Dz for qemu-devel@nongnu.org; Wed, 29 Jul 2009 06:51:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MW6ke-0002gx-4Y for qemu-devel@nongnu.org; Wed, 29 Jul 2009 06:51:20 -0400 Received: from [199.232.76.173] (port=48664 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MW6kd-0002gk-VZ for qemu-devel@nongnu.org; Wed, 29 Jul 2009 06:51:15 -0400 Received: from canardo.mork.no ([148.122.252.1]:41547) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MW6kd-0004Kf-9N for qemu-devel@nongnu.org; Wed, 29 Jul 2009 06:51:15 -0400 From: =?utf-8?q?Bj=C3=B8rn=20Mork?= Date: Wed, 29 Jul 2009 12:51:06 +0200 Message-Id: <1248864666-31387-1-git-send-email-bjorn@mork.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] alsa broken when the host is suspended (or hibernated) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?utf-8?q?Bj=C3=B8rn=20Mork?= audio output fails after resuming a host running a guest using alsa audio output. Messages such as alsa: Failed to write 882 frames to 0x1804b98 alsa: Reason: Streams pipe error will appear repeatedly in the monitor. This is caused by alsaaudio.c not handling ESTRPIPE. Fix this by calling snd_pcm_resume() on ESTRPIPE. This bug is similar to the vlc bug discussed on https://trac.videolan.org/vlc/ticket/1286 and the fix is insired by the patch attached to that bug report Signed-off-by: Bj=C3=B8rn Mork --- audio/alsaaudio.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index d0b7cd0..1c007e5 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -503,6 +503,16 @@ static int alsa_recover (snd_pcm_t *handle) return 0; } =20 +static int alsa_resume (snd_pcm_t *handle) +{ + int err =3D snd_pcm_resume (handle); + if (err < 0) { + alsa_logerr (err, "Failed to resume handle %p\n", handle); + return -1; + } + return 0; +} + static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle) { snd_pcm_sframes_t avail; @@ -580,6 +590,18 @@ static int alsa_run_out (HWVoiceOut *hw) } continue; =20 + case -ESTRPIPE: + /* stream is suspended and waiting for an application recovery */ + if (alsa_resume (alsa->handle)) { + alsa_logerr (written, "Failed to write %d frames= \n", + len); + goto exit; + } + if (conf.verbose) { + dolog ("Resuming suspended stream\n"); + } + continue; + case -EAGAIN: goto exit; =20 --=20 1.5.6.5