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>
+
* gst/base/gstbasesrc.c: (gst_base_src_class_init),
(gst_base_src_init), (gst_base_src_query),
(gst_base_src_default_newsegment),
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (end));
/* 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;
+ }
/* save last times seen. */
basesink->current_start = start;
base_time = GST_ELEMENT (basesink)->base_time;
GST_LOG_OBJECT (basesink,
- "waiting for clock, base time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (base_time));
+ "waiting for clock, base time %" GST_TIME_FORMAT
+ "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
* to signal EOS */
GST_UNLOCK (basesink);
GST_LOG_OBJECT (basesink, "clock entry done: %d", result);
+ } else {
+ GST_DEBUG_OBJECT (basesink, "no clock, not syncing");
}
done:
static void
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);
}
GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull));
gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad);
+ trans->transform_lock = g_mutex_new ();
trans->delay_configure = FALSE;
trans->pending_configure = FALSE;
trans->cache_caps1 = NULL;
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
- /* we cannot run this when we are processing data or doing another
- * negotiation in the streaming thread. */
- GST_STREAM_LOCK (pad);
+ /* we cannot run this when we are transforming data and as such doing
+ * another negotiation in the transform method. */
+ g_mutex_lock (trans->transform_lock);
*buf = NULL;
gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps);
}
- GST_STREAM_UNLOCK (pad);
+ g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans);
gst_buffer_unref (*buf);
*buf = NULL;
}
- GST_STREAM_UNLOCK (pad);
+ g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans);
return GST_FLOW_OK;
}
gst_buffer_unref (*buf);
*buf = NULL;
}
- GST_STREAM_UNLOCK (pad);
+ g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans);
return GST_FLOW_OK;
}
{
GstFormat format;
gdouble rate;
- gint64 start, stop, base;
+ gint64 start, stop, time;
gboolean update;
GST_STREAM_LOCK (pad);
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
- &base);
+ &time);
if (format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
- " -- %" GST_TIME_FORMAT ", base %" GST_TIME_FORMAT,
- start, stop, base);
+ " -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
trans->have_newsegment = TRUE;
trans->segment_start = start;
trans->segment_stop = stop;
- trans->segment_base = base;
+ trans->segment_base = time;
trans->segment_rate = rate;
} else {
GST_DEBUG_OBJECT (trans,
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf);
if (ret == GST_FLOW_OK) {
+ g_mutex_lock (trans->transform_lock);
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer);
+ g_mutex_unlock (trans->transform_lock);
}
gst_object_unref (trans);
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);
+ g_mutex_unlock (trans->transform_lock);
+
if (ret == GST_FLOW_OK) {
ret = gst_pad_push (trans->srcpad, outbuf);
} else if (outbuf != NULL)
/* Set if caps on each pad are equal */
gboolean have_same_caps;
+ GMutex *transform_lock;
+
/*< private >*/
- gpointer _gst_reserved[GST_PADDING - 1];
+ gpointer _gst_reserved[GST_PADDING - 2];
};
/**
", end: %" GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (end));
/* 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;
+ }
/* save last times seen. */
basesink->current_start = start;
base_time = GST_ELEMENT (basesink)->base_time;
GST_LOG_OBJECT (basesink,
- "waiting for clock, base time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (base_time));
+ "waiting for clock, base time %" GST_TIME_FORMAT
+ "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
* to signal EOS */
GST_UNLOCK (basesink);
GST_LOG_OBJECT (basesink, "clock entry done: %d", result);
+ } else {
+ GST_DEBUG_OBJECT (basesink, "no clock, not syncing");
}
done:
static void
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);
}
GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull));
gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad);
+ trans->transform_lock = g_mutex_new ();
trans->delay_configure = FALSE;
trans->pending_configure = FALSE;
trans->cache_caps1 = NULL;
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
- /* we cannot run this when we are processing data or doing another
- * negotiation in the streaming thread. */
- GST_STREAM_LOCK (pad);
+ /* we cannot run this when we are transforming data and as such doing
+ * another negotiation in the transform method. */
+ g_mutex_lock (trans->transform_lock);
*buf = NULL;
gst_caps_unref (srccaps);
gst_caps_unref (sinkcaps);
}
- GST_STREAM_UNLOCK (pad);
+ g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans);
gst_buffer_unref (*buf);
*buf = NULL;
}
- GST_STREAM_UNLOCK (pad);
+ g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans);
return GST_FLOW_OK;
}
gst_buffer_unref (*buf);
*buf = NULL;
}
- GST_STREAM_UNLOCK (pad);
+ g_mutex_unlock (trans->transform_lock);
gst_object_unref (trans);
return GST_FLOW_OK;
}
{
GstFormat format;
gdouble rate;
- gint64 start, stop, base;
+ gint64 start, stop, time;
gboolean update;
GST_STREAM_LOCK (pad);
gst_event_parse_newsegment (event, &update, &rate, &format, &start, &stop,
- &base);
+ &time);
if (format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" GST_TIME_FORMAT
- " -- %" GST_TIME_FORMAT ", base %" GST_TIME_FORMAT,
- start, stop, base);
+ " -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
trans->have_newsegment = TRUE;
trans->segment_start = start;
trans->segment_stop = stop;
- trans->segment_base = base;
+ trans->segment_base = time;
trans->segment_rate = rate;
} else {
GST_DEBUG_OBJECT (trans,
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf);
if (ret == GST_FLOW_OK) {
+ g_mutex_lock (trans->transform_lock);
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer);
+ g_mutex_unlock (trans->transform_lock);
}
gst_object_unref (trans);
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);
+ g_mutex_unlock (trans->transform_lock);
+
if (ret == GST_FLOW_OK) {
ret = gst_pad_push (trans->srcpad, outbuf);
} else if (outbuf != NULL)
/* Set if caps on each pad are equal */
gboolean have_same_caps;
+ GMutex *transform_lock;
+
/*< private >*/
- gpointer _gst_reserved[GST_PADDING - 1];
+ gpointer _gst_reserved[GST_PADDING - 2];
};
/**