gst/base/gstbasesink.c: Some more debugging.

Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync), (gst_base_sink_get_position):
Some more debugging.

* gst/base/gstbasetransform.c: (gst_base_transform_finalize),
(gst_base_transform_init), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_getrange),
(gst_base_transform_chain):
* gst/base/gstbasetransform.h:
Fix debugging,
Protect transform and concurrent buffer alloc with a new lock.
Try not to break ABI/API.
This commit is contained in:
Wim Taymans 2005-10-27 20:59:00 +00:00
parent 2e7411e8b8
commit f2e8f7198f
7 changed files with 85 additions and 30 deletions

View file

@ -1,3 +1,18 @@
2005-10-27 Wim Taymans <wim@fluendo.com>
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync), (gst_base_sink_get_position):
Some more debugging.
* gst/base/gstbasetransform.c: (gst_base_transform_finalize),
(gst_base_transform_init), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_getrange),
(gst_base_transform_chain):
* gst/base/gstbasetransform.h:
Fix debugging,
Protect transform and concurrent buffer alloc with a new lock.
Try not to break ABI/API.
2005-10-27 Wim Taymans <wim@fluendo.com> 2005-10-27 Wim Taymans <wim@fluendo.com>
* gst/base/gstbasesrc.c: (gst_base_src_class_init), * gst/base/gstbasesrc.c: (gst_base_src_class_init),

View file

@ -980,8 +980,10 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (end)); ", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (end));
/* if we don't have a timestamp, we don't sync */ /* if we don't have a timestamp, we don't sync */
if (!start_valid) if (!start_valid) {
GST_DEBUG_OBJECT (basesink, "start not valid");
goto done; goto done;
}
/* save last times seen. */ /* save last times seen. */
basesink->current_start = start; basesink->current_start = start;
@ -1030,8 +1032,9 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
base_time = GST_ELEMENT (basesink)->base_time; base_time = GST_ELEMENT (basesink)->base_time;
GST_LOG_OBJECT (basesink, GST_LOG_OBJECT (basesink,
"waiting for clock, base time %" GST_TIME_FORMAT, "waiting for clock, base time %" GST_TIME_FORMAT
GST_TIME_ARGS (base_time)); "stream_start %" GST_TIME_FORMAT,
GST_TIME_ARGS (base_time), GST_TIME_ARGS (stream_start));
/* also save end_time of this buffer so that we can wait /* also save end_time of this buffer so that we can wait
* to signal EOS */ * to signal EOS */
@ -1045,6 +1048,8 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
GST_UNLOCK (basesink); GST_UNLOCK (basesink);
GST_LOG_OBJECT (basesink, "clock entry done: %d", result); GST_LOG_OBJECT (basesink, "clock entry done: %d", result);
} else {
GST_DEBUG_OBJECT (basesink, "no clock, not syncing");
} }
done: done:

View file

@ -278,6 +278,12 @@ gst_base_transform_base_init (gpointer g_class)
static void static void
gst_base_transform_finalize (GObject * object) gst_base_transform_finalize (GObject * object)
{ {
GstBaseTransform *trans;
trans = GST_BASE_TRANSFORM (object);
g_mutex_free (trans->transform_lock);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -345,6 +351,7 @@ gst_base_transform_init (GstBaseTransform * trans,
GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull)); GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull));
gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad); gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad);
trans->transform_lock = g_mutex_new ();
trans->delay_configure = FALSE; trans->delay_configure = FALSE;
trans->pending_configure = FALSE; trans->pending_configure = FALSE;
trans->cache_caps1 = NULL; trans->cache_caps1 = NULL;
@ -894,9 +901,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
/* we cannot run this when we are processing data or doing another /* we cannot run this when we are transforming data and as such doing
* negotiation in the streaming thread. */ * another negotiation in the transform method. */
GST_STREAM_LOCK (pad); g_mutex_lock (trans->transform_lock);
*buf = NULL; *buf = NULL;
@ -961,7 +968,7 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
gst_caps_unref (srccaps); gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps); gst_caps_unref (sinkcaps);
} }
GST_STREAM_UNLOCK (pad); g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans); gst_object_unref (trans);
@ -975,7 +982,7 @@ not_configured:
gst_buffer_unref (*buf); gst_buffer_unref (*buf);
*buf = NULL; *buf = NULL;
} }
GST_STREAM_UNLOCK (pad); g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans); gst_object_unref (trans);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -987,7 +994,7 @@ unknown_size:
gst_buffer_unref (*buf); gst_buffer_unref (*buf);
*buf = NULL; *buf = NULL;
} }
GST_STREAM_UNLOCK (pad); g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans); gst_object_unref (trans);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -1024,20 +1031,20 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
{ {
GstFormat format; GstFormat format;
gdouble rate; gdouble rate;
gint64 start, stop, base; gint64 start, stop, time;
gboolean update; gboolean update;
GST_STREAM_LOCK (pad); GST_STREAM_LOCK (pad);
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop, gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
&base); &time);
if (format == GST_FORMAT_TIME) { if (format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
" -- %" GST_TIME_FORMAT ", base %" GST_TIME_FORMAT, " -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
start, stop, base); GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
trans->have_newsegment = TRUE; trans->have_newsegment = TRUE;
trans->segment_start = start; trans->segment_start = start;
trans->segment_stop = stop; trans->segment_stop = stop;
trans->segment_base = base; trans->segment_base = time;
trans->segment_rate = rate; trans->segment_rate = rate;
} else { } else {
GST_DEBUG_OBJECT (trans, GST_DEBUG_OBJECT (trans,
@ -1215,7 +1222,9 @@ gst_base_transform_getrange (GstPad * pad, guint64 offset,
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf); ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf);
if (ret == GST_FLOW_OK) { if (ret == GST_FLOW_OK) {
g_mutex_lock (trans->transform_lock);
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer); ret = gst_base_transform_handle_buffer (trans, inbuf, buffer);
g_mutex_unlock (trans->transform_lock);
} }
gst_object_unref (trans); gst_object_unref (trans);
@ -1232,7 +1241,11 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer)
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
/* protect transform method and concurrent buffer alloc */
g_mutex_lock (trans->transform_lock);
ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf); ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf);
g_mutex_unlock (trans->transform_lock);
if (ret == GST_FLOW_OK) { if (ret == GST_FLOW_OK) {
ret = gst_pad_push (trans->srcpad, outbuf); ret = gst_pad_push (trans->srcpad, outbuf);
} else if (outbuf != NULL) } else if (outbuf != NULL)

View file

@ -82,8 +82,10 @@ struct _GstBaseTransform {
/* Set if caps on each pad are equal */ /* Set if caps on each pad are equal */
gboolean have_same_caps; gboolean have_same_caps;
GMutex *transform_lock;
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING - 1]; gpointer _gst_reserved[GST_PADDING - 2];
}; };
/** /**

View file

@ -980,8 +980,10 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (end)); ", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (end));
/* if we don't have a timestamp, we don't sync */ /* if we don't have a timestamp, we don't sync */
if (!start_valid) if (!start_valid) {
GST_DEBUG_OBJECT (basesink, "start not valid");
goto done; goto done;
}
/* save last times seen. */ /* save last times seen. */
basesink->current_start = start; basesink->current_start = start;
@ -1030,8 +1032,9 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
base_time = GST_ELEMENT (basesink)->base_time; base_time = GST_ELEMENT (basesink)->base_time;
GST_LOG_OBJECT (basesink, GST_LOG_OBJECT (basesink,
"waiting for clock, base time %" GST_TIME_FORMAT, "waiting for clock, base time %" GST_TIME_FORMAT
GST_TIME_ARGS (base_time)); "stream_start %" GST_TIME_FORMAT,
GST_TIME_ARGS (base_time), GST_TIME_ARGS (stream_start));
/* also save end_time of this buffer so that we can wait /* also save end_time of this buffer so that we can wait
* to signal EOS */ * to signal EOS */
@ -1045,6 +1048,8 @@ gst_base_sink_do_sync (GstBaseSink * basesink, GstBuffer * buffer)
GST_UNLOCK (basesink); GST_UNLOCK (basesink);
GST_LOG_OBJECT (basesink, "clock entry done: %d", result); GST_LOG_OBJECT (basesink, "clock entry done: %d", result);
} else {
GST_DEBUG_OBJECT (basesink, "no clock, not syncing");
} }
done: done:

View file

@ -278,6 +278,12 @@ gst_base_transform_base_init (gpointer g_class)
static void static void
gst_base_transform_finalize (GObject * object) gst_base_transform_finalize (GObject * object)
{ {
GstBaseTransform *trans;
trans = GST_BASE_TRANSFORM (object);
g_mutex_free (trans->transform_lock);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -345,6 +351,7 @@ gst_base_transform_init (GstBaseTransform * trans,
GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull)); GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull));
gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad); gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad);
trans->transform_lock = g_mutex_new ();
trans->delay_configure = FALSE; trans->delay_configure = FALSE;
trans->pending_configure = FALSE; trans->pending_configure = FALSE;
trans->cache_caps1 = NULL; trans->cache_caps1 = NULL;
@ -894,9 +901,9 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
/* we cannot run this when we are processing data or doing another /* we cannot run this when we are transforming data and as such doing
* negotiation in the streaming thread. */ * another negotiation in the transform method. */
GST_STREAM_LOCK (pad); g_mutex_lock (trans->transform_lock);
*buf = NULL; *buf = NULL;
@ -961,7 +968,7 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
gst_caps_unref (srccaps); gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps); gst_caps_unref (sinkcaps);
} }
GST_STREAM_UNLOCK (pad); g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans); gst_object_unref (trans);
@ -975,7 +982,7 @@ not_configured:
gst_buffer_unref (*buf); gst_buffer_unref (*buf);
*buf = NULL; *buf = NULL;
} }
GST_STREAM_UNLOCK (pad); g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans); gst_object_unref (trans);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -987,7 +994,7 @@ unknown_size:
gst_buffer_unref (*buf); gst_buffer_unref (*buf);
*buf = NULL; *buf = NULL;
} }
GST_STREAM_UNLOCK (pad); g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans); gst_object_unref (trans);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -1024,20 +1031,20 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
{ {
GstFormat format; GstFormat format;
gdouble rate; gdouble rate;
gint64 start, stop, base; gint64 start, stop, time;
gboolean update; gboolean update;
GST_STREAM_LOCK (pad); GST_STREAM_LOCK (pad);
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop, gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
&base); &time);
if (format == GST_FORMAT_TIME) { if (format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
" -- %" GST_TIME_FORMAT ", base %" GST_TIME_FORMAT, " -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
start, stop, base); GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
trans->have_newsegment = TRUE; trans->have_newsegment = TRUE;
trans->segment_start = start; trans->segment_start = start;
trans->segment_stop = stop; trans->segment_stop = stop;
trans->segment_base = base; trans->segment_base = time;
trans->segment_rate = rate; trans->segment_rate = rate;
} else { } else {
GST_DEBUG_OBJECT (trans, GST_DEBUG_OBJECT (trans,
@ -1215,7 +1222,9 @@ gst_base_transform_getrange (GstPad * pad, guint64 offset,
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf); ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf);
if (ret == GST_FLOW_OK) { if (ret == GST_FLOW_OK) {
g_mutex_lock (trans->transform_lock);
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer); ret = gst_base_transform_handle_buffer (trans, inbuf, buffer);
g_mutex_unlock (trans->transform_lock);
} }
gst_object_unref (trans); gst_object_unref (trans);
@ -1232,7 +1241,11 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer)
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
/* protect transform method and concurrent buffer alloc */
g_mutex_lock (trans->transform_lock);
ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf); ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf);
g_mutex_unlock (trans->transform_lock);
if (ret == GST_FLOW_OK) { if (ret == GST_FLOW_OK) {
ret = gst_pad_push (trans->srcpad, outbuf); ret = gst_pad_push (trans->srcpad, outbuf);
} else if (outbuf != NULL) } else if (outbuf != NULL)

View file

@ -82,8 +82,10 @@ struct _GstBaseTransform {
/* Set if caps on each pad are equal */ /* Set if caps on each pad are equal */
gboolean have_same_caps; gboolean have_same_caps;
GMutex *transform_lock;
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING - 1]; gpointer _gst_reserved[GST_PADDING - 2];
}; };
/** /**