From 391c82601faac30bc68033b69d924dd5a3ba0052 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 25 May 2005 11:57:45 +0000 Subject: [PATCH] ext/alsa/gstalsasink.c: Open non-blocking, set to blocking mode afterwards to avoid lockups when audio device is busy. Original commit message from CVS: * ext/alsa/gstalsasink.c: (gst_alsasink_open): Open non-blocking, set to blocking mode afterwards to avoid lockups when audio device is busy. --- ChangeLog | 6 ++++++ ext/alsa/gstalsasink.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac947371e4..c608548eb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-25 Wim Taymans + + * ext/alsa/gstalsasink.c: (gst_alsasink_open): + Open non-blocking, set to blocking mode afterwards to avoid + lockups when audio device is busy. + 2005-05-23 Ronald S. Bultje * gst-libs/gst/audio/gstringbuffer.c: (gst_ringbuffer_clear): diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index 578cddf8a4..43cd41a809 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -429,8 +429,10 @@ gst_alsasink_open (GstAudioSink * asink, GstRingBufferSpec * spec) if (!alsasink_parse_spec (alsa, spec)) goto spec_parse; - CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, 0), - open_error); + CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, + SND_PCM_NONBLOCK), open_error); + + CHECK (snd_pcm_nonblock (alsa->handle, 0), non_block); CHECK (set_hwparams (alsa), hw_params_failed); CHECK (set_swparams (alsa), sw_params_failed); @@ -459,6 +461,12 @@ open_error: ("Playback open error: %s", snd_strerror (err)), (NULL)); return FALSE; } +non_block: + { + GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ, + ("Could not set device to blocking: %s", snd_strerror (err)), (NULL)); + return FALSE; + } hw_params_failed: { GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_READ,