2005-07-18 Wim Taymans <wim@fluendo.com>
+ * gst/base/gstbasesink.c: (gst_base_sink_pad_getcaps),
+ (gst_base_sink_pad_setcaps), (gst_base_sink_pad_buffer_alloc),
+ (gst_base_sink_preroll_queue_flush), (gst_base_sink_handle_object),
+ (gst_base_sink_event), (gst_base_sink_do_sync),
+ (gst_base_sink_chain), (gst_base_sink_loop),
+ (gst_base_sink_deactivate), (gst_base_sink_activate_push),
+ (gst_base_sink_activate_pull), (gst_base_sink_change_state):
+ Refcounting fixes.
+ Fix logic for returning ASYNC when not prerolled.
+
+2005-07-18 Wim Taymans <wim@fluendo.com>
+
* gst/gstqueue.c: (gst_queue_handle_sink_event):
Fix nasty refcount bug.
GstBaseSink *bsink;
GstCaps *caps = NULL;
- bsink = GST_BASE_SINK (GST_PAD_PARENT (pad));
+ bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->get_caps)
caps = bclass->get_caps (bsink);
caps = gst_caps_ref (gst_pad_template_get_caps (pad_template));
}
}
+ gst_object_unref (bsink);
return caps;
}
GstBaseSink *bsink;
gboolean res = FALSE;
- bsink = GST_BASE_SINK (GST_PAD_PARENT (pad));
+ bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->set_caps)
res = bclass->set_caps (bsink, caps);
+ gst_object_unref (bsink);
+
return res;
}
GstBaseSink *bsink;
GstFlowReturn result = GST_FLOW_OK;
- bsink = GST_BASE_SINK (GST_PAD_PARENT (pad));
+ bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->buffer_alloc)
else
*buf = NULL;
+ gst_object_unref (bsink);
+
return result;
}
basesink->preroll_queued = 0;
basesink->buffers_queued = 0;
basesink->events_queued = 0;
+ basesink->have_preroll = FALSE;
/* and signal any waiters now */
GST_PREROLL_SIGNAL (pad);
}
GST_DEBUG ("prerolled length %d", length);
if (length == 1) {
- guint t;
+ gint t;
basesink->have_preroll = TRUE;
/* we are prerolling */
* inside the STREAM_LOCK */
t = GST_STREAM_UNLOCK_FULL (pad);
GST_DEBUG ("released stream lock %d times", t);
- if (t == 0) {
+ if (t <= 0) {
GST_WARNING ("STREAM_LOCK should have been locked !!");
g_warning ("STREAM_LOCK should have been locked !!");
}
goto no_preroll;
length = basesink->preroll_queued;
+
+ g_assert (length == 1);
}
/* see if we need to block now. We cannot block on events, only
GST_ELEMENT_NAME (basesink));
GST_PREROLL_WAIT (pad);
GST_DEBUG ("done preroll");
- basesink->have_preroll = FALSE;
}
GST_LOCK (pad);
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
flushing:
{
GST_UNLOCK (pad);
- basesink->have_preroll = FALSE;
+ gst_base_sink_preroll_queue_flush (basesink, pad);
GST_PREROLL_UNLOCK (pad);
GST_DEBUG ("pad is flushing");
return GST_FLOW_WRONG_STATE;
}
preroll_failed:
{
- guint t;
+ gint t;
GST_DEBUG ("preroll failed");
- basesink->have_preroll = FALSE;
gst_base_sink_preroll_queue_flush (basesink, pad);
GST_PREROLL_UNLOCK (pad);
* inside the STREAM_LOCK */
t = GST_STREAM_UNLOCK_FULL (pad);
GST_DEBUG ("released stream lock %d times", t);
- if (t == 0) {
+ if (t <= 0) {
GST_WARNING ("STREAM_LOCK should have been locked !!");
g_warning ("STREAM_LOCK should have been locked !!");
}
gboolean result = TRUE;
GstBaseSinkClass *bclass;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (basesink);
GST_STREAM_LOCK (pad);
GST_STREAM_UNLOCK (pad);
}
-
+ GST_DEBUG ("event unref %p %p", basesink, event);
+ gst_event_unref (event);
break;
default:
- result = gst_pad_event_default (pad, event);
+ gst_event_unref (event);
break;
}
+ gst_object_unref (basesink);
return result;
}
GstBaseSink *basesink;
GstFlowReturn result;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
result = gst_base_sink_handle_object (basesink, pad, GST_MINI_OBJECT (buf));
+ gst_object_unref (basesink);
+
return result;
}
GstBuffer *buf = NULL;
GstFlowReturn result;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
g_assert (basesink->pad_mode == GST_ACTIVATE_PULL);
if (result != GST_FLOW_OK)
goto paused;
+ gst_object_unref (basesink);
+
/* default */
return;
paused:
{
+ gst_object_unref (basesink);
gst_pad_pause_task (pad);
return;
}
/* flush out the data thread if it's locked in finish_preroll */
basesink->need_preroll = FALSE;
gst_base_sink_preroll_queue_flush (basesink, pad);
+ GST_PREROLL_SIGNAL (pad);
GST_PREROLL_UNLOCK (pad);
/* step 2, make sure streaming finishes */
gboolean result = FALSE;
GstBaseSink *basesink;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
if (active) {
- g_return_val_if_fail (basesink->has_chain, FALSE);
+ if (!basesink->has_chain)
+ goto done;
result = TRUE;
} else {
result = gst_base_sink_deactivate (basesink, pad);
}
basesink->pad_mode = GST_ACTIVATE_PUSH;
+done:
+ gst_object_unref (basesink);
+
return result;
}
gboolean result = FALSE;
GstBaseSink *basesink;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
if (active) {
/* if we have a scheduler we can start the task */
- g_return_val_if_fail (basesink->has_loop, FALSE);
+ if (!basesink->has_loop)
+ goto done;
result =
gst_pad_start_task (pad, (GstTaskFunction) gst_base_sink_loop, pad);
} else {
result = gst_base_sink_deactivate (basesink, pad);
}
+done:
+ gst_object_unref (basesink);
return result;
}
}
/* don't need the preroll anymore */
basesink->need_preroll = FALSE;
- if (basesink->have_preroll) {
- /* now let it play */
- GST_PREROLL_SIGNAL (basesink->sinkpad);
- }
+ /* now let it play */
+ GST_PREROLL_SIGNAL (basesink->sinkpad);
GST_PREROLL_UNLOCK (basesink->sinkpad);
break;
}
GstBaseSink *bsink;
GstCaps *caps = NULL;
- bsink = GST_BASE_SINK (GST_PAD_PARENT (pad));
+ bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->get_caps)
caps = bclass->get_caps (bsink);
caps = gst_caps_ref (gst_pad_template_get_caps (pad_template));
}
}
+ gst_object_unref (bsink);
return caps;
}
GstBaseSink *bsink;
gboolean res = FALSE;
- bsink = GST_BASE_SINK (GST_PAD_PARENT (pad));
+ bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->set_caps)
res = bclass->set_caps (bsink, caps);
+ gst_object_unref (bsink);
+
return res;
}
GstBaseSink *bsink;
GstFlowReturn result = GST_FLOW_OK;
- bsink = GST_BASE_SINK (GST_PAD_PARENT (pad));
+ bsink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (bsink);
if (bclass->buffer_alloc)
else
*buf = NULL;
+ gst_object_unref (bsink);
+
return result;
}
basesink->preroll_queued = 0;
basesink->buffers_queued = 0;
basesink->events_queued = 0;
+ basesink->have_preroll = FALSE;
/* and signal any waiters now */
GST_PREROLL_SIGNAL (pad);
}
GST_DEBUG ("prerolled length %d", length);
if (length == 1) {
- guint t;
+ gint t;
basesink->have_preroll = TRUE;
/* we are prerolling */
* inside the STREAM_LOCK */
t = GST_STREAM_UNLOCK_FULL (pad);
GST_DEBUG ("released stream lock %d times", t);
- if (t == 0) {
+ if (t <= 0) {
GST_WARNING ("STREAM_LOCK should have been locked !!");
g_warning ("STREAM_LOCK should have been locked !!");
}
goto no_preroll;
length = basesink->preroll_queued;
+
+ g_assert (length == 1);
}
/* see if we need to block now. We cannot block on events, only
GST_ELEMENT_NAME (basesink));
GST_PREROLL_WAIT (pad);
GST_DEBUG ("done preroll");
- basesink->have_preroll = FALSE;
}
GST_LOCK (pad);
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
flushing:
{
GST_UNLOCK (pad);
- basesink->have_preroll = FALSE;
+ gst_base_sink_preroll_queue_flush (basesink, pad);
GST_PREROLL_UNLOCK (pad);
GST_DEBUG ("pad is flushing");
return GST_FLOW_WRONG_STATE;
}
preroll_failed:
{
- guint t;
+ gint t;
GST_DEBUG ("preroll failed");
- basesink->have_preroll = FALSE;
gst_base_sink_preroll_queue_flush (basesink, pad);
GST_PREROLL_UNLOCK (pad);
* inside the STREAM_LOCK */
t = GST_STREAM_UNLOCK_FULL (pad);
GST_DEBUG ("released stream lock %d times", t);
- if (t == 0) {
+ if (t <= 0) {
GST_WARNING ("STREAM_LOCK should have been locked !!");
g_warning ("STREAM_LOCK should have been locked !!");
}
gboolean result = TRUE;
GstBaseSinkClass *bclass;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
bclass = GST_BASE_SINK_GET_CLASS (basesink);
GST_STREAM_LOCK (pad);
GST_STREAM_UNLOCK (pad);
}
-
+ GST_DEBUG ("event unref %p %p", basesink, event);
+ gst_event_unref (event);
break;
default:
- result = gst_pad_event_default (pad, event);
+ gst_event_unref (event);
break;
}
+ gst_object_unref (basesink);
return result;
}
GstBaseSink *basesink;
GstFlowReturn result;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
result = gst_base_sink_handle_object (basesink, pad, GST_MINI_OBJECT (buf));
+ gst_object_unref (basesink);
+
return result;
}
GstBuffer *buf = NULL;
GstFlowReturn result;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
g_assert (basesink->pad_mode == GST_ACTIVATE_PULL);
if (result != GST_FLOW_OK)
goto paused;
+ gst_object_unref (basesink);
+
/* default */
return;
paused:
{
+ gst_object_unref (basesink);
gst_pad_pause_task (pad);
return;
}
/* flush out the data thread if it's locked in finish_preroll */
basesink->need_preroll = FALSE;
gst_base_sink_preroll_queue_flush (basesink, pad);
+ GST_PREROLL_SIGNAL (pad);
GST_PREROLL_UNLOCK (pad);
/* step 2, make sure streaming finishes */
gboolean result = FALSE;
GstBaseSink *basesink;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
if (active) {
- g_return_val_if_fail (basesink->has_chain, FALSE);
+ if (!basesink->has_chain)
+ goto done;
result = TRUE;
} else {
result = gst_base_sink_deactivate (basesink, pad);
}
basesink->pad_mode = GST_ACTIVATE_PUSH;
+done:
+ gst_object_unref (basesink);
+
return result;
}
gboolean result = FALSE;
GstBaseSink *basesink;
- basesink = GST_BASE_SINK (GST_OBJECT_PARENT (pad));
+ basesink = GST_BASE_SINK (gst_pad_get_parent (pad));
if (active) {
/* if we have a scheduler we can start the task */
- g_return_val_if_fail (basesink->has_loop, FALSE);
+ if (!basesink->has_loop)
+ goto done;
result =
gst_pad_start_task (pad, (GstTaskFunction) gst_base_sink_loop, pad);
} else {
result = gst_base_sink_deactivate (basesink, pad);
}
+done:
+ gst_object_unref (basesink);
return result;
}
}
/* don't need the preroll anymore */
basesink->need_preroll = FALSE;
- if (basesink->have_preroll) {
- /* now let it play */
- GST_PREROLL_SIGNAL (basesink->sinkpad);
- }
+ /* now let it play */
+ GST_PREROLL_SIGNAL (basesink->sinkpad);
GST_PREROLL_UNLOCK (basesink->sinkpad);
break;
}