mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 17:05:52 +00:00
fix all kinds of shutdown stuff and do proper freeing of memory
Original commit message from CVS: fix all kinds of shutdown stuff and do proper freeing of memory
This commit is contained in:
parent
4b1649ad34
commit
245d6e4d6d
1 changed files with 26 additions and 2 deletions
|
@ -79,6 +79,7 @@ static GstElementDetails gst_alsa_src_details = {
|
||||||
/* GObject functions */
|
/* GObject functions */
|
||||||
static void gst_alsa_class_init (GstAlsaClass *klass);
|
static void gst_alsa_class_init (GstAlsaClass *klass);
|
||||||
static void gst_alsa_init (GstAlsa *this);
|
static void gst_alsa_init (GstAlsa *this);
|
||||||
|
static void gst_alsa_dispose (GObject *object);
|
||||||
static void gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
static void gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||||
static void gst_alsa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
static void gst_alsa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||||
|
|
||||||
|
@ -240,6 +241,7 @@ gst_alsa_class_init (GstAlsaClass *klass)
|
||||||
if (parent_class == NULL)
|
if (parent_class == NULL)
|
||||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
|
object_class->dispose = gst_alsa_dispose;
|
||||||
object_class->get_property = gst_alsa_get_property;
|
object_class->get_property = gst_alsa_get_property;
|
||||||
object_class->set_property = gst_alsa_set_property;
|
object_class->set_property = gst_alsa_set_property;
|
||||||
|
|
||||||
|
@ -286,6 +288,7 @@ gst_alsa_init (GstAlsa *this)
|
||||||
this->stream = SND_PCM_STREAM_CAPTURE;
|
this->stream = SND_PCM_STREAM_CAPTURE;
|
||||||
gst_element_set_loop_function (GST_ELEMENT (this), gst_alsa_src_loop);
|
gst_element_set_loop_function (GST_ELEMENT (this), gst_alsa_src_loop);
|
||||||
this->pads[0].pad = gst_pad_new_from_template (gst_alsa_src_pad_factory (), "src");
|
this->pads[0].pad = gst_pad_new_from_template (gst_alsa_src_pad_factory (), "src");
|
||||||
|
this->pads[0].bs = NULL;
|
||||||
gst_pad_set_bufferpool_function(this->pads[0].pad, gst_alsa_src_get_buffer_pool);
|
gst_pad_set_bufferpool_function(this->pads[0].pad, gst_alsa_src_get_buffer_pool);
|
||||||
|
|
||||||
/* set the rate to a sensible value. we can't have gobject construct this
|
/* set the rate to a sensible value. we can't have gobject construct this
|
||||||
|
@ -306,6 +309,19 @@ gst_alsa_init (GstAlsa *this)
|
||||||
gst_pad_set_link_function (this->pads[0].pad, gst_alsa_link);
|
gst_pad_set_link_function (this->pads[0].pad, gst_alsa_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_alsa_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GstAlsa *this = GST_ALSA (object);
|
||||||
|
|
||||||
|
for (i = 0; i < ((GstElement *) this)->numpads; i++) {
|
||||||
|
if (this->pads[i].bs)
|
||||||
|
gst_bytestream_destroy (this->pads[i].bs);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
static void
|
static void
|
||||||
gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value,
|
gst_alsa_set_property (GObject *object, guint prop_id, const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
|
@ -811,6 +827,7 @@ static GstElementStateReturn
|
||||||
gst_alsa_change_state (GstElement *element)
|
gst_alsa_change_state (GstElement *element)
|
||||||
{
|
{
|
||||||
GstAlsa *this;
|
GstAlsa *this;
|
||||||
|
gint i;
|
||||||
|
|
||||||
g_return_val_if_fail (element != NULL, FALSE);
|
g_return_val_if_fail (element != NULL, FALSE);
|
||||||
this = GST_ALSA (element);
|
this = GST_ALSA (element);
|
||||||
|
@ -832,14 +849,21 @@ gst_alsa_change_state (GstElement *element)
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
case GST_STATE_PLAYING_TO_PAUSED:
|
||||||
if (GST_ALSA_CAPS_IS_SET(this, GST_ALSA_CAPS_PAUSE)) {
|
if (GST_ALSA_CAPS_IS_SET(this, GST_ALSA_CAPS_PAUSE)) {
|
||||||
if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING)
|
if (snd_pcm_state (this->handle) == SND_PCM_STATE_RUNNING)
|
||||||
snd_pcm_pause (this->handle, 1);
|
snd_pcm_pause (this->handle, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* if device doesn't know how to pause, we just stop */
|
/* if device doesn't know how to pause, we just stop */
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING))
|
if (GST_FLAG_IS_SET (element, GST_ALSA_RUNNING))
|
||||||
gst_alsa_drain_audio (this);
|
gst_alsa_drain_audio (this);
|
||||||
|
/* clear format and pads */
|
||||||
|
g_free (this->format);
|
||||||
|
this->format = NULL;
|
||||||
|
for (i = 0; i < element->numpads; i++) {
|
||||||
|
if (this->pads[i].bs)
|
||||||
|
gst_bytestream_reset (this->pads[i].bs);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
if (GST_FLAG_IS_SET (element, GST_ALSA_OPEN))
|
if (GST_FLAG_IS_SET (element, GST_ALSA_OPEN))
|
||||||
|
|
Loading…
Reference in a new issue