Commit 44e474f7 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

alsa: Ignore errors when unpreparing or closing the device

Errors could happen here when the device was removed already
or when something is broken anyway. If errors happen here and
they're propagated, the element can't shutdown cleanly.

Fixes bug #614545.
parent 1e8f3f76
......@@ -764,52 +764,27 @@ static gboolean
gst_alsasink_unprepare (GstAudioSink * asink)
{
GstAlsaSink *alsa;
gint err;
alsa = GST_ALSA_SINK (asink);
CHECK (snd_pcm_drop (alsa->handle), drop);
CHECK (snd_pcm_hw_free (alsa->handle), hw_free);
snd_pcm_drop (alsa->handle);
snd_pcm_hw_free (alsa->handle);
return TRUE;
/* ERRORS */
drop:
{
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Could not drop samples: %s", snd_strerror (err)));
return FALSE;
}
hw_free:
{
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Could not free hw params: %s", snd_strerror (err)));
return FALSE;
}
}
static gboolean
gst_alsasink_close (GstAudioSink * asink)
{
GstAlsaSink *alsa = GST_ALSA_SINK (asink);
gint err;
if (alsa->handle) {
CHECK (snd_pcm_close (alsa->handle), close_error);
snd_pcm_close (alsa->handle);
alsa->handle = NULL;
}
gst_caps_replace (&alsa->cached_caps, NULL);
return TRUE;
/* ERRORS */
close_error:
{
GST_ELEMENT_ERROR (alsa, RESOURCE, CLOSE, (NULL),
("Playback close error: %s", snd_strerror (err)));
return FALSE;
}
}
......
......@@ -693,37 +693,14 @@ static gboolean
gst_alsasrc_unprepare (GstAudioSrc * asrc)
{
GstAlsaSrc *alsa;
gint err;
alsa = GST_ALSA_SRC (asrc);
CHECK (snd_pcm_drop (alsa->handle), drop);
CHECK (snd_pcm_hw_free (alsa->handle), hw_free);
CHECK (snd_pcm_nonblock (alsa->handle, 1), non_block);
snd_pcm_drop (alsa->handle);
snd_pcm_hw_free (alsa->handle);
snd_pcm_nonblock (alsa->handle, 1);
return TRUE;
/* ERRORS */
drop:
{
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Could not drop samples: %s", snd_strerror (err)));
return FALSE;
}
hw_free:
{
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Could not free hw params: %s", snd_strerror (err)));
return FALSE;
}
non_block:
{
GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL),
("Could not set device to nonblocking: %s", snd_strerror (err)));
return FALSE;
}
}
static gboolean
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment