From d769aaaf9974a39a4a5b4992118c4c8b4b34c32e Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Tue, 15 May 2001 01:45:16 +0000 Subject: [PATCH] gstinfo.c: one more check to make sure DEBUG_FUNCPTR_NAME doesn't go south gstpad.c: debugging changes gsttypefind.c:... Original commit message from CVS: gstinfo.c: one more check to make sure DEBUG_FUNCPTR_NAME doesn't go south gstpad.c: debugging changes gsttypefind.c: moved gst_pad_set_caps to *before* the caps_changed signal gstautoplugcache.c: added refcounting around signal_emit, and debug updates gstautoplugger.c: added code to remove the autoplugcache when done --- gst/autoplug/gstautoplugcache.c | 8 +++-- gst/autoplug/gstautoplugger.c | 53 ++++++++++++++++++++++++++++----- gst/gstinfo.c | 2 +- gst/gstpad.c | 7 +++-- gst/gsttypefind.c | 4 +-- 5 files changed, 60 insertions(+), 14 deletions(-) diff --git a/gst/autoplug/gstautoplugcache.c b/gst/autoplug/gstautoplugcache.c index 9af4172bf3..92331868c6 100644 --- a/gst/autoplug/gstautoplugcache.c +++ b/gst/autoplug/gstautoplugcache.c @@ -223,11 +223,14 @@ gst_autoplugcache_loop (GstElement *element) if (cache->fire_empty) { int oldstate = GST_STATE(cache); fprintf(stderr,"at front of cache, about to pull, but firing signal\n"); + gst_object_ref (GST_OBJECT (cache)); gtk_signal_emit (GTK_OBJECT(cache), gst_autoplugcache_signals[CACHE_EMPTY], NULL); if (GST_STATE(cache) != oldstate) { + gst_object_ref (GST_OBJECT (cache)); GST_DEBUG(GST_CAT_AUTOPLUG, "state changed during signal, aborting\n"); cothread_switch(cothread_current_main()); } + gst_object_unref (GST_OBJECT (cache)); } // get a buffer @@ -293,9 +296,10 @@ gst_autoplugcache_set_arg (GtkObject *object, GtkArg *arg, guint id) switch (id) { case ARG_CAPS_PROXY: cache->caps_proxy = GTK_VALUE_BOOL(*arg); +GST_DEBUG(0,"caps_proxy is %d\n",cache->caps_proxy); if (cache->caps_proxy) { - gst_pad_set_negotiate_function (cache->sinkpad, gst_autoplugcache_nego_sink); - gst_pad_set_negotiate_function (cache->srcpad, gst_autoplugcache_nego_src); + gst_pad_set_negotiate_function (cache->sinkpad, GST_DEBUG_FUNCPTR(gst_autoplugcache_nego_sink)); + gst_pad_set_negotiate_function (cache->srcpad, GST_DEBUG_FUNCPTR(gst_autoplugcache_nego_src)); } else { gst_pad_set_negotiate_function (cache->sinkpad, NULL); gst_pad_set_negotiate_function (cache->srcpad, NULL); diff --git a/gst/autoplug/gstautoplugger.c b/gst/autoplug/gstautoplugger.c index eab5c51907..623c1dc4c3 100644 --- a/gst/autoplug/gstautoplugger.c +++ b/gst/autoplug/gstautoplugger.c @@ -89,6 +89,7 @@ static void gst_autoplugger_external_src_connected (GstPad *pad, GstPad *peerpa static void gst_autoplugger_typefind_have_type (GstElement *element, GstCaps *caps, GstAutoplugger *autoplugger); static void gst_autoplugger_cache_first_buffer (GstElement *element,GstBuffer *buf,GstAutoplugger *autoplugger); +static void gst_autoplugger_cache_empty (GstElement *element, GstAutoplugger *autoplugger); static GstElementClass *parent_class = NULL; //static guint gst_autoplugger_signals[LAST_SIGNAL] = { 0 }; @@ -201,19 +202,19 @@ gst_autoplugger_external_sink_connected(GstPad *pad, GstPad *peerpad, GstAutoplu GstPadTemplate *peertemplate; GstCaps *peercaps, *peertemplatecaps; - GST_INFO(GST_CAT_AUTOPLUG, "have cache:sink connected\n"); + GST_INFO(GST_CAT_AUTOPLUG, "have cache:sink connected"); autoplugger->sinkpadpeer = peerpad; if (autoplugger->sinkpadpeer) { peercaps = GST_PAD_CAPS(autoplugger->sinkpadpeer); if (peercaps) - GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer: %s\n", + GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer: %s", gst_caps_get_mime(peercaps)); peertemplate = GST_PAD_PADTEMPLATE(autoplugger->sinkpadpeer); if (peertemplate) { peertemplatecaps = GST_PADTEMPLATE_CAPS(peertemplate); if (peertemplatecaps) { - GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer's padtemplate %s\n", + GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer's padtemplate %s", gst_caps_get_mime(peertemplatecaps)); GST_DEBUG(GST_CAT_AUTOPLUG, "turning on caps nego proxying in cache\n"); gtk_object_set(GTK_OBJECT(autoplugger->cache),"caps_proxy",TRUE,NULL); @@ -228,19 +229,22 @@ gst_autoplugger_external_src_connected(GstPad *pad, GstPad *peerpad, GstAutoplug GstPadTemplate *peertemplate; GstCaps *peercaps, *peertemplatecaps; - GST_INFO(GST_CAT_AUTOPLUG, "have cache:src connected\n"); - autoplugger->srcpadpeer = peerpad; + GST_INFO(GST_CAT_AUTOPLUG, "have cache:src connected"); + + // only save this off if it isn't a pad we're using internally... + if (peerpad != autoplugger->typefind_sinkpad) + autoplugger->srcpadpeer = peerpad; if (autoplugger->srcpadpeer) { peercaps = GST_PAD_CAPS(autoplugger->srcpadpeer); if (peercaps) - GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer: %s\n", + GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer: %s", gst_caps_get_mime(peercaps)); peertemplate = GST_PAD_PADTEMPLATE(autoplugger->srcpadpeer); if (peertemplate) { peertemplatecaps = GST_PADTEMPLATE_CAPS(peertemplate); if (peertemplatecaps) { - GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer's padtemplate %s\n", + GST_INFO(GST_CAT_AUTOPLUG, "there are some caps on this pad's peer's padtemplate %s", gst_caps_get_mime(peertemplatecaps)); GST_DEBUG(GST_CAT_AUTOPLUG, "turning on caps nego proxying in cache\n"); gtk_object_set(GTK_OBJECT(autoplugger->cache),"caps_proxy",TRUE,NULL); @@ -249,6 +253,36 @@ gst_autoplugger_external_src_connected(GstPad *pad, GstPad *peerpad, GstAutoplug } } +static void +gst_autoplugger_cache_empty(GstElement *element, GstAutoplugger *autoplugger) +{ + GstPad *cache_srcpad_peer; + + GST_INFO(GST_CAT_AUTOPLUG, "autoplugger cache has hit empty, we can now remove it"); + +// try to PAUSE the whole thing +gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED); + + // disconnect the cache from its peers + GST_DEBUG(GST_CAT_AUTOPLUG, "disconnecting autoplugcache from its peers\n"); + gst_pad_disconnect(autoplugger->sinkpadpeer,autoplugger->cache_sinkpad); + cache_srcpad_peer = GST_PAD (GST_PAD_PEER(autoplugger->cache_srcpad)); + gst_pad_disconnect(autoplugger->cache_srcpad,cache_srcpad_peer); + + // remove the cache from self + GST_DEBUG(GST_CAT_AUTOPLUG, "removing the cache from the autoplugger\n"); + gst_bin_remove (GST_BIN(autoplugger), autoplugger->cache); + + // connect the two pads + GST_DEBUG(GST_CAT_AUTOPLUG, "reconnecting the autoplugcache's former peers\n"); + gst_pad_connect(autoplugger->sinkpadpeer,cache_srcpad_peer); + +// try to PLAY the whole thing +gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING); + + GST_INFO(GST_CAT_AUTOPLUG, "autoplugger_cache_empty finished"); +} + static void gst_autoplugger_typefind_have_type(GstElement *element, GstCaps *caps, GstAutoplugger *autoplugger) { @@ -275,6 +309,11 @@ gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PAUSED); GST_DEBUG(GST_CAT_AUTOPLUG, "resetting the cache to send first buffer(s) again\n"); gtk_object_set(GTK_OBJECT(autoplugger->cache),"reset",TRUE,NULL); + // attach the cache_empty handler + // FIXME this is the wrong place, it shouldn't be done until we get successful caps nego! + gtk_signal_connect(GTK_OBJECT(autoplugger->cache),"cache_empty", + GTK_SIGNAL_FUNC(gst_autoplugger_cache_empty),autoplugger); + // try to PLAY the whole thing gst_element_set_state(GST_ELEMENT_SCHED(autoplugger)->parent,GST_STATE_PLAYING); diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 93cb5a9832..91cbd03e18 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -447,7 +447,7 @@ _gst_debug_nameof_funcptr (void *ptr) if (__gst_function_pointers) { if ((ptrname = g_hash_table_lookup(__gst_function_pointers,ptr))) return g_strdup(ptrname); - } else if (dladdr(ptr,&dlinfo)) { + } else if (dladdr(ptr,&dlinfo) && dlinfo.dli_sname) { return g_strdup(dlinfo.dli_sname); } else { return g_strdup_printf("%p",ptr); diff --git a/gst/gstpad.c b/gst/gstpad.c index 01720f2044..fd5a631c60 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -554,8 +554,8 @@ gst_pad_disconnect (GstPad *srcpad, g_return_if_fail (sinkpad != NULL); g_return_if_fail (GST_IS_PAD (sinkpad)); - GST_INFO (GST_CAT_ELEMENT_PADS, "disconnecting %s:%s(%p) and %s:%s", - GST_DEBUG_PAD_NAME(srcpad), srcpad, GST_DEBUG_PAD_NAME(sinkpad)); + GST_INFO (GST_CAT_ELEMENT_PADS, "disconnecting %s:%s(%p) and %s:%s(%p)", + GST_DEBUG_PAD_NAME(srcpad), srcpad, GST_DEBUG_PAD_NAME(sinkpad), sinkpad); // now we need to deal with the real/ghost stuff realsrc = GST_PAD_REALIZE(srcpad); @@ -615,6 +615,9 @@ gst_pad_connect (GstPad *srcpad, g_return_val_if_fail(sinkpad != NULL, FALSE); g_return_val_if_fail(GST_IS_PAD(sinkpad), FALSE); + GST_INFO (GST_CAT_ELEMENT_PADS, "connecting %s:%s and %s:%s", + GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad)); + // now we need to deal with the real/ghost stuff realsrc = GST_PAD_REALIZE(srcpad); realsink = GST_PAD_REALIZE(sinkpad); diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 8cf427b336..7928923b53 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -184,6 +184,8 @@ gst_typefind_chain (GstPad *pad, GstBuffer *buf) gst_caps_get_name (caps)); typefind->caps = caps; + gst_pad_set_caps (pad, caps); + { int oldstate = GST_STATE(typefind); gst_object_ref (GST_OBJECT (typefind)); @@ -196,8 +198,6 @@ gst_typefind_chain (GstPad *pad, GstBuffer *buf) } gst_object_unref (GST_OBJECT (typefind)); } - - gst_pad_set_caps (pad, caps); goto end; } funcs = g_slist_next (funcs);