diff --git a/ChangeLog b/ChangeLog index 037943909c..1b0e9fbffc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-07-08 Thomas Vander Stichele + + * gst/autoplug/gstspideridentity.c: (gst_spider_identity_chain): + extra debugging + * gst/gstevent.h: + * gst/gstinfo.c: (gst_debug_log_default): + print time nicely. add thread pointer until someone figures out + a completely portable way of getting at thread id's. + * gst/gstpad.c: (gst_pad_set_active), (gst_pad_link_try), + (_invent_event), (gst_pad_pull), (gst_pad_event_default_dispatch), + (gst_pad_call_chain_function): + extra debugging + * gst/schedulers/gstoptimalscheduler.c: + (get_group_schedule_function), (loop_group_schedule_function), + (gst_opt_scheduler_loop_wrapper), (gst_opt_scheduler_get_wrapper), + (pad_clear_queued), (gst_opt_scheduler_iterate): + rename BUFPEN and friends to DATAPEN since that's what they are. + 2004-07-07 Thomas Vander Stichele * gst/autoplug/gstspideridentity.c: (gst_spider_identity_chain): diff --git a/gst/autoplug/gstspideridentity.c b/gst/autoplug/gstspideridentity.c index e7331b3187..c4a4bd6e46 100644 --- a/gst/autoplug/gstspideridentity.c +++ b/gst/autoplug/gstspideridentity.c @@ -182,6 +182,7 @@ gst_spider_identity_chain (GstPad * pad, GstBuffer * buf) ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); if (GST_IS_EVENT (buf)) { + GST_DEBUG_OBJECT (ident, "spider identity received event %p", buf); /* start hack for current event stuff here */ /* check for unlinked elements and send them the EOS event, too */ if (GST_EVENT_TYPE (GST_EVENT (buf)) == GST_EVENT_EOS) { @@ -193,15 +194,21 @@ gst_spider_identity_chain (GstPad * pad, GstBuffer * buf) list = g_list_next (list); if (conn->current != (GstElement *) conn->src) { - GST_DEBUG ("sending EOS to unconnected element %s from %s", - GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident)); - gst_pad_push (conn->src->src, - GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS)))); + GstEvent *event; + + event = gst_event_new (GST_EVENT_EOS); + GST_DEBUG_OBJECT (ident, + "sending EOS event %p to unconnected element %s from %s", + event, GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident)); + gst_pad_push (conn->src->src, GST_DATA (event)); gst_element_set_eos (GST_ELEMENT (conn->src)); } } } /* end hack for current event stuff here */ + GST_DEBUG_OBJECT (ident, + "calling default handler for event %p on pad %s:%s", + buf, GST_DEBUG_PAD_NAME (pad)); gst_pad_event_default (pad, GST_EVENT (buf)); return; diff --git a/gst/gstevent.h b/gst/gstevent.h index 4c65e1cd32..c8e4b5a7ba 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -51,7 +51,7 @@ typedef enum { GST_EVENT_TS_OFFSET = 13, GST_EVENT_INTERRUPT = 14, GST_EVENT_NAVIGATION = 15, - GST_EVENT_TAG = 16 + GST_EVENT_TAG = 16 } GstEventType; #define GST_EVENT_ANY GST_EVENT_NAVIGATION diff --git a/gst/gstinfo.c b/gst/gstinfo.c index e0fa8f8880..adfbd5c086 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -508,11 +508,11 @@ gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level, obj = object ? gst_debug_print_object (object) : g_strdup (""); g_get_current_time (&now); - g_printerr ("%s (%10ld:%06ld) %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n", - gst_debug_level_get_name (level), - now.tv_sec, now.tv_usec, - color, gst_debug_category_get_name (category), clear, - pidcolor, pid, clear, + g_printerr ("%s (%p - %" GST_TIME_FORMAT + ") %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n", + gst_debug_level_get_name (level), g_thread_self (), + GST_TIME_ARGS (GST_TIMEVAL_TO_TIME (now)), color, + gst_debug_category_get_name (category), clear, pidcolor, pid, clear, color, file, line, function, obj, clear, gst_debug_message_get (message)); g_free (color); diff --git a/gst/gstpad.c b/gst/gstpad.c index 19e6aedff9..35662e17af 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -36,8 +36,8 @@ GST_DEBUG_CATEGORY_STATIC (debug_dataflow); #define DEBUG_DATA(obj,data,notice) G_STMT_START{\ if (GST_IS_EVENT (data)) { \ - GST_CAT_DEBUG_OBJECT (debug_dataflow, obj, "%s event %p (type %d)", notice, data, \ - GST_EVENT_TYPE (data)); \ + GST_CAT_DEBUG_OBJECT (debug_dataflow, obj, "%s event %p (type %d, refcount %d)", notice, data, \ + GST_EVENT_TYPE (data), GST_DATA_REFCOUNT_VALUE (data)); \ } else { \ GST_CAT_LOG_OBJECT (debug_dataflow, obj, "%s buffer %p (size %u, refcount %d)", notice, data, \ GST_BUFFER_SIZE (data), GST_BUFFER_REFCOUNT_VALUE (data)); \ @@ -470,7 +470,7 @@ gst_pad_set_active (GstPad * pad, gboolean active) if (link) { if (link->temp_store) { GST_CAT_INFO (GST_CAT_PADS, - "deleting cached buffer from bufpen of pad %s:%s", + "deleting cached data %p from bufpen of pad %s:%s", link->temp_store, GST_DEBUG_PAD_NAME (realpad)); gst_data_unref (link->temp_store); link->temp_store = NULL; @@ -1392,6 +1392,7 @@ gst_pad_link_try (GstPadLink * link) if (oldlink) { GST_DEBUG ("copying stuff from oldlink"); link->temp_store = oldlink->temp_store; + GST_DEBUG ("moving old data temp store %p", link->temp_store); link->engaged = oldlink->engaged; oldlink->temp_store = NULL; gst_pad_link_free (oldlink); @@ -3123,14 +3124,14 @@ _invent_event (GstPad * pad, GstBuffer * buffer) event = gst_event_new_discontinuous (TRUE, GST_FORMAT_TIME, timestamp, event_type, offset, GST_FORMAT_UNDEFINED); GST_CAT_WARNING (GST_CAT_SCHEDULING, - "needed to invent a DISCONT (time %" G_GUINT64_FORMAT - ") for %s:%s => %s:%s", timestamp, + "needed to invent a DISCONT %p (time %" G_GUINT64_FORMAT + ") for %s:%s => %s:%s", event, timestamp, GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad)), GST_DEBUG_PAD_NAME (pad)); } else { event = gst_event_new_discontinuous (TRUE, event_type, offset, GST_FORMAT_UNDEFINED); GST_CAT_WARNING (GST_CAT_SCHEDULING, - "needed to invent a DISCONT (no time) for %s:%s => %s:%s", + "needed to invent a DISCONT %p (no time) for %s:%s => %s:%s", event, GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad)), GST_DEBUG_PAD_NAME (pad)); } @@ -3238,6 +3239,7 @@ gst_pad_pull (GstPad * pad) if (link->temp_store) { g_assert (link->engaged); + GST_DEBUG ("moving temp_store %p to data", link->temp_store); data = link->temp_store; link->temp_store = NULL; } else { @@ -3251,6 +3253,7 @@ gst_pad_pull (GstPad * pad) if (!link->engaged) { g_assert (link->temp_store == NULL); if (GST_IS_BUFFER (data)) { + GST_DEBUG ("moving data buffer %p back to temp_store", data); link->temp_store = data; link->engaged = TRUE; data = _invent_event (pad, GST_BUFFER (data)); @@ -3259,10 +3262,11 @@ gst_pad_pull (GstPad * pad) GST_EVENT_DISCONT_NEW_MEDIA (data)) { link->engaged = TRUE; GST_CAT_LOG (GST_CAT_SCHEDULING, - "link engaged by discont event for pad %s:%s", + "link engaged by discont event %p for pad %s:%s", data, GST_DEBUG_PAD_NAME (pad)); } } + GST_DEBUG ("calling gst_probe_dispatcher_dispatch on data %p", data); if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) goto restart; DEBUG_DATA (pad, data, "gst_pad_pull returned"); @@ -3932,19 +3936,26 @@ gst_pad_event_default_dispatch (GstPad * pad, GstElement * element, /* for all of the internally-linked pads that are actually linked */ if (GST_PAD_IS_LINKED (eventpad)) { if (GST_PAD_DIRECTION (eventpad) == GST_PAD_SRC) { - /* increase the refcount */ + /* for each pad we send to, we should ref the event; it's up + * to downstream to unref again when handled. */ + GST_LOG_OBJECT (pad, "Reffing and sending event %p to %s:%s", event, + GST_DEBUG_PAD_NAME (eventpad)); gst_event_ref (event); gst_pad_push (eventpad, GST_DATA (event)); } else { GstPad *peerpad = GST_PAD (GST_RPAD_PEER (eventpad)); - /* we only send the event on one pad, multi-sinkpad elements + /* we only send the event on one pad, multi-sinkpad elements * should implement a handler */ g_list_free (orig); + GST_LOG_OBJECT (pad, "sending event %p to one sink pad %s:%s", event, + GST_DEBUG_PAD_NAME (eventpad)); return gst_pad_send_event (peerpad, event); } } } + /* we handled the incoming event so we unref once */ + GST_LOG_OBJECT (pad, "handled event %p, unreffing", event); gst_event_unref (event); g_list_free (orig); return (GST_PAD_DIRECTION (pad) == GST_PAD_SINK); @@ -4340,6 +4351,7 @@ gst_pad_call_chain_function (GstPad * pad, GstData * data) if (!link->engaged) { g_assert (link->temp_store == NULL); if (GST_IS_BUFFER (data)) { + GST_DEBUG ("moving data buffer %p back to temp_store", data); link->temp_store = data; link->engaged = TRUE; CALL_CHAINFUNC (pad, _invent_event (pad, GST_BUFFER (data))); @@ -4353,7 +4365,7 @@ gst_pad_call_chain_function (GstPad * pad, GstData * data) GST_EVENT_DISCONT_NEW_MEDIA (data)) { link->engaged = TRUE; GST_CAT_LOG (GST_CAT_SCHEDULING, - "link engaged by discont event for pad %s:%s", + "link engaged by discont event %p for pad %s:%s", data, GST_DEBUG_PAD_NAME (pad)); } } diff --git a/gst/schedulers/gstoptimalscheduler.c b/gst/schedulers/gstoptimalscheduler.c index abf3acc4ab..d4a712dcb1 100644 --- a/gst/schedulers/gstoptimalscheduler.c +++ b/gst/schedulers/gstoptimalscheduler.c @@ -39,8 +39,8 @@ GST_DEBUG_CATEGORY_STATIC (debug_scheduler); #define GST_ELEMENT_SCHED_CONTEXT(elem) ((GstOptSchedulerCtx*) (GST_ELEMENT (elem)->sched_private)) #define GST_ELEMENT_SCHED_GROUP(elem) (GST_ELEMENT_SCHED_CONTEXT (elem)->group) /* need this first macro to not run into lvalue casts */ -#define GST_PAD_BUFPEN(pad) (GST_REAL_PAD(pad)->sched_private) -#define GST_PAD_BUFLIST(pad) ((GList*) GST_PAD_BUFPEN(pad)) +#define GST_PAD_DATAPEN(pad) (GST_REAL_PAD(pad)->sched_private) +#define GST_PAD_DATALIST(pad) ((GList*) GST_PAD_DATAPEN(pad)) #define GST_ELEMENT_COTHREAD_STOPPING GST_ELEMENT_SCHEDULER_PRIVATE1 #define GST_ELEMENT_IS_COTHREAD_STOPPING(element) GST_FLAG_IS_SET((element), GST_ELEMENT_COTHREAD_STOPPING) @@ -651,7 +651,7 @@ merge_chains (GstOptSchedulerChain * chain1, GstOptSchedulerChain * chain2) } /* sorts the group list so that terminal sinks come first -- prevents pileup of - * buffers in bufpens */ + * datas in datapens */ static void sort_chain (GstOptSchedulerChain * chain) { @@ -1245,6 +1245,7 @@ get_group_schedule_function (int argc, char *argv[]) data = gst_pad_call_get_function (pad); if (data) { if (GST_EVENT_IS_INTERRUPT (data)) { + GST_DEBUG ("unreffing interrupt event %p", data); gst_event_unref (GST_EVENT (data)); break; } @@ -1279,7 +1280,7 @@ loop_group_schedule_function (int argc, char *argv[]) else group_error_handler (group); - GST_LOG ("loopfunc ended of element %s in group %p", + GST_LOG ("returned from loopfunc of element %s in group %p", GST_ELEMENT_NAME (entry), group); group->flags &= ~GST_OPT_SCHEDULER_GROUP_RUNNING; @@ -1303,7 +1304,7 @@ unknown_group_schedule_function (int argc, char *argv[]) /* this function is called when the first element of a chain-loop or a loop-loop * link performs a push to the loop element. We then schedule the - * group with the loop-based element until the bufpen is empty */ + * group with the loop-based element until the datapen is empty */ static void gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data) { @@ -1318,19 +1319,19 @@ gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data) GST_LOG ("chain handler for loop-based pad %" GST_PTR_FORMAT, sinkpad); #ifdef USE_COTHREADS - if (GST_PAD_BUFLIST (peer)) { + if (GST_PAD_DATALIST (peer)) { g_warning ("deadlock detected, disabling group %p", group); group_error_handler (group); } else { - GST_LOG ("queueing data %p on %s:%s's bufpen", data, + GST_LOG ("queueing data %p on %s:%s's datapen", data, GST_DEBUG_PAD_NAME (peer)); - GST_PAD_BUFPEN (peer) = g_list_append (GST_PAD_BUFLIST (peer), data); + GST_PAD_DATAPEN (peer) = g_list_append (GST_PAD_DATALIST (peer), data); schedule_group (group); } #else - GST_LOG ("queueing data %p on %s:%s's bufpen", data, + GST_LOG ("queueing data %p on %s:%s's datapen", data, GST_DEBUG_PAD_NAME (peer)); - GST_PAD_BUFPEN (peer) = g_list_append (GST_PAD_BUFLIST (peer), data); + GST_PAD_DATAPEN (peer) = g_list_append (GST_PAD_DATALIST (peer), data); if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { GST_LOG ("adding group %p to runqueue", group); if (!g_list_find (osched->runqueue, group)) { @@ -1340,13 +1341,13 @@ gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data) } #endif - GST_LOG ("%d buffers left on %s:%s's bufpen after chain handler", - g_list_length (GST_PAD_BUFLIST (peer)), GST_DEBUG_PAD_NAME (peer)); + GST_LOG ("%d datas left on %s:%s's datapen after chain handler", + g_list_length (GST_PAD_DATALIST (peer)), GST_DEBUG_PAD_NAME (peer)); } /* this function is called by a loop based element that performs a - * pull on a sinkpad. We schedule the peer group until the bufpen - * is filled with the buffer so that this function can return */ + * pull on a sinkpad. We schedule the peer group until the datapen + * is filled with the data so that this function can return */ static GstData * gst_opt_scheduler_get_wrapper (GstPad * srcpad) { @@ -1357,10 +1358,10 @@ gst_opt_scheduler_get_wrapper (GstPad * srcpad) GST_LOG ("get handler for %" GST_PTR_FORMAT, srcpad); - /* first try to grab a queued buffer */ - if (GST_PAD_BUFLIST (srcpad)) { - data = GST_PAD_BUFLIST (srcpad)->data; - GST_PAD_BUFPEN (srcpad) = g_list_remove (GST_PAD_BUFLIST (srcpad), data); + /* first try to grab a queued data */ + if (GST_PAD_DATALIST (srcpad)) { + data = GST_PAD_DATALIST (srcpad)->data; + GST_PAD_DATAPEN (srcpad) = g_list_remove (GST_PAD_DATALIST (srcpad), data); GST_LOG ("returning popped queued data %p", data); @@ -1374,7 +1375,7 @@ gst_opt_scheduler_get_wrapper (GstPad * srcpad) disabled = FALSE; do { - GST_LOG ("scheduling upstream group %p to fill bufpen", group); + GST_LOG ("scheduling upstream group %p to fill datapen", group); #ifdef USE_COTHREADS schedule_group (group); #else @@ -1406,18 +1407,18 @@ gst_opt_scheduler_get_wrapper (GstPad * srcpad) return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); } #endif - /* if the scheduler interrupted, make sure we send an INTERRUPTED event to the - * loop based element */ + /* if the scheduler interrupted, make sure we send an INTERRUPTED event + * to the loop based element */ if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) { GST_INFO ("scheduler interrupted, return interrupt event"); data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); } else { - if (GST_PAD_BUFLIST (srcpad)) { - data = GST_PAD_BUFLIST (srcpad)->data; - GST_PAD_BUFPEN (srcpad) = - g_list_remove (GST_PAD_BUFLIST (srcpad), data); + if (GST_PAD_DATALIST (srcpad)) { + data = GST_PAD_DATALIST (srcpad)->data; + GST_PAD_DATAPEN (srcpad) = + g_list_remove (GST_PAD_DATALIST (srcpad), data); } else if (disabled) { - /* no buffer in queue and peer group was disabled */ + /* no data in queue and peer group was disabled */ data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); } } @@ -1425,7 +1426,7 @@ gst_opt_scheduler_get_wrapper (GstPad * srcpad) while (data == NULL); GST_LOG ("get handler, returning data %p, queue length %d", - data, g_list_length (GST_PAD_BUFLIST (srcpad))); + data, g_list_length (GST_PAD_DATALIST (srcpad))); return data; } @@ -1433,13 +1434,13 @@ gst_opt_scheduler_get_wrapper (GstPad * srcpad) static void pad_clear_queued (GstPad * srcpad, gpointer user_data) { - GList *buflist = GST_PAD_BUFLIST (srcpad); + GList *datalist = GST_PAD_DATALIST (srcpad); - if (buflist) { - GST_LOG ("need to clear some buffers"); - g_list_foreach (buflist, (GFunc) gst_data_unref, NULL); - g_list_free (buflist); - GST_PAD_BUFPEN (srcpad) = NULL; + if (datalist) { + GST_LOG ("need to clear some datas"); + g_list_foreach (datalist, (GFunc) gst_data_unref, NULL); + g_list_free (datalist); + GST_PAD_DATAPEN (srcpad) = NULL; } } @@ -2383,6 +2384,7 @@ gst_opt_scheduler_iterate (GstScheduler * sched) GST_LOG ("scheduling chain %p", chain); schedule_chain (chain); scheduled = TRUE; + GST_LOG ("scheduled chain %p", chain); } else { GST_LOG ("not scheduling disabled chain %p", chain); }