From fd8559e4fbea6b3c3255d74310dcdd4c7fbb5e86 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 25 May 2009 13:03:42 +0200 Subject: [PATCH] pad: keep task ref before releasing the lock Keep a ref to the task on the pad so that a concurrent stop can stop and join the task. --- gst/gstpad.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index 3eb8a41..e4ca3d7 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -5127,16 +5127,19 @@ gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer data) gst_task_set_lock (task, GST_PAD_GET_STREAM_LOCK (pad)); gst_task_set_thread_callbacks (task, &thr_callbacks, pad, NULL); GST_DEBUG_OBJECT (pad, "created task"); + GST_PAD_TASK (pad) = task; + gst_object_ref (task); /* release lock to post the message */ GST_OBJECT_UNLOCK (pad); do_stream_status (pad, GST_STREAM_STATUS_TYPE_CREATE, NULL, task); + gst_object_unref (task); + GST_OBJECT_LOCK (pad); /* nobody else is supposed to have changed the pad now */ - if (GST_PAD_TASK (pad) != NULL) - goto concurrent_start; - GST_PAD_TASK (pad) = task; + if (GST_PAD_TASK (pad) != task) + goto concurrent_stop; } res = gst_task_set_state (task, GST_TASK_STARTED); GST_OBJECT_UNLOCK (pad); @@ -5144,13 +5147,10 @@ gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer data) return res; /* ERRORS */ -concurrent_start: +concurrent_stop: { - g_warning ("two threads started pad %s:%s at the same time", - GST_DEBUG_PAD_NAME (pad)); GST_OBJECT_UNLOCK (pad); - gst_object_unref (task); - return FALSE; + return TRUE; } } -- 2.7.4