From 576b2181d856ce2009c6e48991cdfb06ff75a5e6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 17 May 2005 17:37:43 +0000 Subject: [PATCH] gst/: Don't queue buffers in basesink when we are flushing. Original commit message from CVS: * gst/base/gstbasesink.c: (gst_basesink_finish_preroll), (gst_basesink_chain_unlocked), (gst_basesink_activate): * gst/gstminiobject.c: (gst_mini_object_get_type), (gst_mini_object_free): * gst/gstpad.c: (gst_pad_accept_caps), (gst_pad_query), (gst_pad_push), (gst_pad_push_event): * gst/gstqueue.c: (gst_queue_change_state): Don't queue buffers in basesink when we are flushing. Unref buffer when flushing in basesink. Flush queue when going to READY Unref buffer when _push() returns an error. Don't free MiniObject instance when refcount is incremented in _finalize() so that we can recover objects. --- ChangeLog | 16 ++++++++++++++++ gst/base/gstbasesink.c | 5 +++-- gst/gstminiobject.c | 7 +++++-- gst/gstpad.c | 6 ++++++ gst/gstqueue.c | 4 ++-- libs/gst/base/gstbasesink.c | 5 +++-- plugins/elements/gstqueue.c | 4 ++-- 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9794689426..d78be45a6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-05-17 Wim Taymans + + * gst/base/gstbasesink.c: (gst_basesink_finish_preroll), + (gst_basesink_chain_unlocked), (gst_basesink_activate): + * gst/gstminiobject.c: (gst_mini_object_get_type), + (gst_mini_object_free): + * gst/gstpad.c: (gst_pad_accept_caps), (gst_pad_query), + (gst_pad_push), (gst_pad_push_event): + * gst/gstqueue.c: (gst_queue_change_state): + Don't queue buffers in basesink when we are flushing. + Unref buffer when flushing in basesink. + Flush queue when going to READY + Unref buffer when _push() returns an error. + Don't free MiniObject instance when refcount is incremented + in _finalize() so that we can recover objects. + 2005-05-17 Thomas Vander Stichele * docs/manual/advanced-schedulers.xml: diff --git a/gst/base/gstbasesink.c b/gst/base/gstbasesink.c index 4382590fca..ca038dfa7e 100644 --- a/gst/base/gstbasesink.c +++ b/gst/base/gstbasesink.c @@ -446,14 +446,14 @@ gst_basesink_finish_preroll (GstBaseSink * basesink, GstPad * pad, gst_element_commit_state (GST_ELEMENT (basesink)); GST_STATE_UNLOCK (basesink); - gst_basesink_preroll_queue_push (basesink, pad, buffer); - GST_LOCK (pad); usable = !GST_RPAD_IS_FLUSHING (pad) && GST_RPAD_IS_ACTIVE (pad); GST_UNLOCK (pad); if (!usable) goto unusable; + gst_basesink_preroll_queue_push (basesink, pad, buffer); + if (basesink->need_preroll) goto still_queueing; @@ -695,6 +695,7 @@ gst_basesink_chain_unlocked (GstPad * pad, GstBuffer * buf) case PREROLL_PLAYING: return gst_basesink_handle_buffer (basesink, buf); case PREROLL_FLUSHING: + gst_buffer_unref (buf); return GST_FLOW_UNEXPECTED; default: g_assert_not_reached (); diff --git a/gst/gstminiobject.c b/gst/gstminiobject.c index 3bfd238258..23cf591fb9 100644 --- a/gst/gstminiobject.c +++ b/gst/gstminiobject.c @@ -46,7 +46,7 @@ static gchar *gst_value_mini_object_lcopy (const GValue * value, GType gst_mini_object_get_type (void) { - static GType _gst_mini_object_type; + static GType _gst_mini_object_type = 0; if (!_gst_mini_object_type) { GTypeValueTable value_table = { @@ -178,7 +178,10 @@ gst_mini_object_free (GstMiniObject * mini_object) mo_class = GST_MINI_OBJECT_GET_CLASS (mini_object); mo_class->finalize (mini_object); - g_type_free_instance ((GTypeInstance *) mini_object); + /* if the refcount is still 0 we can really free the + * object, else the finalize method recycled the object */ + if (g_atomic_int_get (&mini_object->refcount) == 0) + g_type_free_instance ((GTypeInstance *) mini_object); } void diff --git a/gst/gstpad.c b/gst/gstpad.c index 5f68e80f3a..8379f43d1d 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2902,6 +2902,7 @@ gst_pad_push (GstPad * pad, GstBuffer * buffer) /* ERROR recovery here */ not_linked: { + gst_buffer_unref (buffer); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "pushing, but it was not linked"); GST_UNLOCK (pad); @@ -2909,6 +2910,7 @@ not_linked: } not_active: { + gst_buffer_unref (buffer); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "pushing, but it was inactive"); GST_UNLOCK (pad); @@ -2916,6 +2918,7 @@ not_active: } flushing: { + gst_buffer_unref (buffer); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "pushing, but pad was flushing"); GST_UNLOCK (pad); @@ -2923,12 +2926,14 @@ flushing: } not_negotiated: { + gst_buffer_unref (buffer); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "pushing buffer but peer did not accept"); return GST_FLOW_NOT_NEGOTIATED; } no_function: { + gst_buffer_unref (buffer); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "pushing, but not chainhandler"); GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), @@ -3132,6 +3137,7 @@ gst_pad_push_event (GstPad * pad, GstEvent * event) /* ERROR handling */ not_linked: { + gst_event_unref (event); GST_UNLOCK (pad); return FALSE; } diff --git a/gst/gstqueue.c b/gst/gstqueue.c index fb52be20fc..2fd8f6e897 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -906,12 +906,12 @@ gst_queue_change_state (GstElement * element) switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: + break; + case GST_STATE_READY_TO_PAUSED: GST_QUEUE_MUTEX_LOCK; gst_queue_locked_flush (queue); GST_QUEUE_MUTEX_UNLOCK; break; - case GST_STATE_READY_TO_PAUSED: - break; case GST_STATE_PAUSED_TO_PLAYING: break; default: diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 4382590fca..ca038dfa7e 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -446,14 +446,14 @@ gst_basesink_finish_preroll (GstBaseSink * basesink, GstPad * pad, gst_element_commit_state (GST_ELEMENT (basesink)); GST_STATE_UNLOCK (basesink); - gst_basesink_preroll_queue_push (basesink, pad, buffer); - GST_LOCK (pad); usable = !GST_RPAD_IS_FLUSHING (pad) && GST_RPAD_IS_ACTIVE (pad); GST_UNLOCK (pad); if (!usable) goto unusable; + gst_basesink_preroll_queue_push (basesink, pad, buffer); + if (basesink->need_preroll) goto still_queueing; @@ -695,6 +695,7 @@ gst_basesink_chain_unlocked (GstPad * pad, GstBuffer * buf) case PREROLL_PLAYING: return gst_basesink_handle_buffer (basesink, buf); case PREROLL_FLUSHING: + gst_buffer_unref (buf); return GST_FLOW_UNEXPECTED; default: g_assert_not_reached (); diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index fb52be20fc..2fd8f6e897 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -906,12 +906,12 @@ gst_queue_change_state (GstElement * element) switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: + break; + case GST_STATE_READY_TO_PAUSED: GST_QUEUE_MUTEX_LOCK; gst_queue_locked_flush (queue); GST_QUEUE_MUTEX_UNLOCK; break; - case GST_STATE_READY_TO_PAUSED: - break; case GST_STATE_PAUSED_TO_PLAYING: break; default: