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.
This commit is contained in:
Wim Taymans 2005-05-17 17:37:43 +00:00
parent 1c175ed067
commit 576b2181d8
7 changed files with 37 additions and 10 deletions

View file

@ -1,3 +1,19 @@
2005-05-17 Wim Taymans <wim@fluendo.com>
* 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 <thomas at apestaart dot org> 2005-05-17 Thomas Vander Stichele <thomas at apestaart dot org>
* docs/manual/advanced-schedulers.xml: * docs/manual/advanced-schedulers.xml:

View file

@ -446,14 +446,14 @@ gst_basesink_finish_preroll (GstBaseSink * basesink, GstPad * pad,
gst_element_commit_state (GST_ELEMENT (basesink)); gst_element_commit_state (GST_ELEMENT (basesink));
GST_STATE_UNLOCK (basesink); GST_STATE_UNLOCK (basesink);
gst_basesink_preroll_queue_push (basesink, pad, buffer);
GST_LOCK (pad); GST_LOCK (pad);
usable = !GST_RPAD_IS_FLUSHING (pad) && GST_RPAD_IS_ACTIVE (pad); usable = !GST_RPAD_IS_FLUSHING (pad) && GST_RPAD_IS_ACTIVE (pad);
GST_UNLOCK (pad); GST_UNLOCK (pad);
if (!usable) if (!usable)
goto unusable; goto unusable;
gst_basesink_preroll_queue_push (basesink, pad, buffer);
if (basesink->need_preroll) if (basesink->need_preroll)
goto still_queueing; goto still_queueing;
@ -695,6 +695,7 @@ gst_basesink_chain_unlocked (GstPad * pad, GstBuffer * buf)
case PREROLL_PLAYING: case PREROLL_PLAYING:
return gst_basesink_handle_buffer (basesink, buf); return gst_basesink_handle_buffer (basesink, buf);
case PREROLL_FLUSHING: case PREROLL_FLUSHING:
gst_buffer_unref (buf);
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
default: default:
g_assert_not_reached (); g_assert_not_reached ();

View file

@ -46,7 +46,7 @@ static gchar *gst_value_mini_object_lcopy (const GValue * value,
GType GType
gst_mini_object_get_type (void) gst_mini_object_get_type (void)
{ {
static GType _gst_mini_object_type; static GType _gst_mini_object_type = 0;
if (!_gst_mini_object_type) { if (!_gst_mini_object_type) {
GTypeValueTable value_table = { 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 = GST_MINI_OBJECT_GET_CLASS (mini_object);
mo_class->finalize (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 void

View file

@ -2902,6 +2902,7 @@ gst_pad_push (GstPad * pad, GstBuffer * buffer)
/* ERROR recovery here */ /* ERROR recovery here */
not_linked: not_linked:
{ {
gst_buffer_unref (buffer);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"pushing, but it was not linked"); "pushing, but it was not linked");
GST_UNLOCK (pad); GST_UNLOCK (pad);
@ -2909,6 +2910,7 @@ not_linked:
} }
not_active: not_active:
{ {
gst_buffer_unref (buffer);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"pushing, but it was inactive"); "pushing, but it was inactive");
GST_UNLOCK (pad); GST_UNLOCK (pad);
@ -2916,6 +2918,7 @@ not_active:
} }
flushing: flushing:
{ {
gst_buffer_unref (buffer);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"pushing, but pad was flushing"); "pushing, but pad was flushing");
GST_UNLOCK (pad); GST_UNLOCK (pad);
@ -2923,12 +2926,14 @@ flushing:
} }
not_negotiated: not_negotiated:
{ {
gst_buffer_unref (buffer);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"pushing buffer but peer did not accept"); "pushing buffer but peer did not accept");
return GST_FLOW_NOT_NEGOTIATED; return GST_FLOW_NOT_NEGOTIATED;
} }
no_function: no_function:
{ {
gst_buffer_unref (buffer);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad,
"pushing, but not chainhandler"); "pushing, but not chainhandler");
GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL),
@ -3132,6 +3137,7 @@ gst_pad_push_event (GstPad * pad, GstEvent * event)
/* ERROR handling */ /* ERROR handling */
not_linked: not_linked:
{ {
gst_event_unref (event);
GST_UNLOCK (pad); GST_UNLOCK (pad);
return FALSE; return FALSE;
} }

View file

@ -906,12 +906,12 @@ gst_queue_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY: case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
GST_QUEUE_MUTEX_LOCK; GST_QUEUE_MUTEX_LOCK;
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
GST_QUEUE_MUTEX_UNLOCK; GST_QUEUE_MUTEX_UNLOCK;
break; break;
case GST_STATE_READY_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
break; break;
default: default:

View file

@ -446,14 +446,14 @@ gst_basesink_finish_preroll (GstBaseSink * basesink, GstPad * pad,
gst_element_commit_state (GST_ELEMENT (basesink)); gst_element_commit_state (GST_ELEMENT (basesink));
GST_STATE_UNLOCK (basesink); GST_STATE_UNLOCK (basesink);
gst_basesink_preroll_queue_push (basesink, pad, buffer);
GST_LOCK (pad); GST_LOCK (pad);
usable = !GST_RPAD_IS_FLUSHING (pad) && GST_RPAD_IS_ACTIVE (pad); usable = !GST_RPAD_IS_FLUSHING (pad) && GST_RPAD_IS_ACTIVE (pad);
GST_UNLOCK (pad); GST_UNLOCK (pad);
if (!usable) if (!usable)
goto unusable; goto unusable;
gst_basesink_preroll_queue_push (basesink, pad, buffer);
if (basesink->need_preroll) if (basesink->need_preroll)
goto still_queueing; goto still_queueing;
@ -695,6 +695,7 @@ gst_basesink_chain_unlocked (GstPad * pad, GstBuffer * buf)
case PREROLL_PLAYING: case PREROLL_PLAYING:
return gst_basesink_handle_buffer (basesink, buf); return gst_basesink_handle_buffer (basesink, buf);
case PREROLL_FLUSHING: case PREROLL_FLUSHING:
gst_buffer_unref (buf);
return GST_FLOW_UNEXPECTED; return GST_FLOW_UNEXPECTED;
default: default:
g_assert_not_reached (); g_assert_not_reached ();

View file

@ -906,12 +906,12 @@ gst_queue_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY: case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
GST_QUEUE_MUTEX_LOCK; GST_QUEUE_MUTEX_LOCK;
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
GST_QUEUE_MUTEX_UNLOCK; GST_QUEUE_MUTEX_UNLOCK;
break; break;
case GST_STATE_READY_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
break; break;
default: default: