mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-07 08:39:54 +00:00
updated autoplugcache so it can be removed mid-signal, now autoplugtest works
Original commit message from CVS: updated autoplugcache so it can be removed mid-signal, now autoplugtest works
This commit is contained in:
parent
5bb3603feb
commit
aec5a57022
4 changed files with 37 additions and 6 deletions
|
@ -2,6 +2,26 @@
|
|||
|
||||
GstElement *pipeline, *src, *autobin, *cache, *typefind, *decoder, *sink;
|
||||
|
||||
void cache_empty(GstElement *element, gpointer private) {
|
||||
fprintf(stderr,"have cache empty\n");
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
|
||||
gst_element_disconnect(src,"src",cache,"sink");
|
||||
gst_schedule_show (GST_ELEMENT_SCHED(pipeline));
|
||||
gst_element_disconnect(cache,"src",decoder,"sink");
|
||||
gst_schedule_show (GST_ELEMENT_SCHED(pipeline));
|
||||
gst_bin_remove (GST_BIN(autobin), cache);
|
||||
gst_schedule_show (GST_ELEMENT_SCHED(pipeline));
|
||||
gst_element_connect(src,"src",decoder,"sink");
|
||||
gst_schedule_show (GST_ELEMENT_SCHED(pipeline));
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
gst_schedule_show (GST_ELEMENT_SCHED(pipeline));
|
||||
|
||||
fprintf(stderr,"done with cache_empty\n");
|
||||
}
|
||||
|
||||
void have_type(GstElement *element, GstCaps *caps, GstCaps **private_caps) {
|
||||
fprintf(stderr,"have caps, mime type is %s\n",gst_caps_get_mime(caps));
|
||||
|
||||
|
@ -15,11 +35,13 @@ void have_type(GstElement *element, GstCaps *caps, GstCaps **private_caps) {
|
|||
|
||||
if (strstr(gst_caps_get_mime(caps),"mp3")) {
|
||||
decoder = gst_elementfactory_make ("mad","decoder");
|
||||
sink = gst_elementfactory_make ("esdsink","sink");
|
||||
sink = gst_elementfactory_make ("osssink","sink");
|
||||
gst_bin_add(GST_BIN(autobin),decoder);
|
||||
gst_bin_add(GST_BIN(autobin),sink);
|
||||
gst_element_connect(decoder,"src",sink,"sink");
|
||||
|
||||
gtk_object_set (GTK_OBJECT(cache), "reset", TRUE, NULL);
|
||||
|
||||
gst_element_connect(cache,"src",decoder,"sink");
|
||||
}
|
||||
else if (strstr(gst_caps_get_mime(caps),"x-ogg")) {
|
||||
|
@ -29,6 +51,8 @@ void have_type(GstElement *element, GstCaps *caps, GstCaps **private_caps) {
|
|||
gst_bin_add(GST_BIN(autobin),sink);
|
||||
gst_element_connect(decoder,"src",sink,"sink");
|
||||
|
||||
gtk_object_set (GTK_OBJECT(cache), "reset", TRUE, NULL);
|
||||
|
||||
gst_element_connect(cache,"src",decoder,"sink");
|
||||
}
|
||||
|
||||
|
@ -49,6 +73,7 @@ int main (int argc,char *argv[]) {
|
|||
|
||||
autobin = gst_bin_new("autobin");
|
||||
cache = gst_elementfactory_make ("autoplugcache","cache");
|
||||
gtk_signal_connect (GTK_OBJECT(cache),"cache_empty",GTK_SIGNAL_FUNC(cache_empty),NULL);
|
||||
typefind = gst_elementfactory_make ("typefind", "typefind");
|
||||
gtk_signal_connect (GTK_OBJECT(typefind),"have_type",GTK_SIGNAL_FUNC(have_type),&caps);
|
||||
gst_bin_add (GST_BIN(autobin),cache);
|
||||
|
|
|
@ -201,8 +201,13 @@ gst_autoplugcache_loop (GstElement *element)
|
|||
|
||||
// if we've been told to fire an empty signal (after a reset)
|
||||
if (cache->fire_empty) {
|
||||
int oldstate = GST_STATE(cache);
|
||||
fprintf(stderr,"at front of cache, about to pull, but firing signal\n");
|
||||
gtk_signal_emit (GTK_OBJECT(cache), gst_autoplugcache_signals[CACHE_EMPTY], NULL);
|
||||
if (GST_STATE(cache) != oldstate) {
|
||||
GST_DEBUG(GST_CAT_AUTOPLUG, "state changed during signal, aborting\n");
|
||||
cothread_switch(cothread_current_main());
|
||||
}
|
||||
}
|
||||
|
||||
// get a buffer
|
||||
|
|
|
@ -811,13 +811,15 @@ gst_element_change_state (GstElement *element)
|
|||
GST_DEBUG (GST_CAT_STATES, "default handler sets '%s' state to %s\n",
|
||||
GST_ELEMENT_NAME (element), _gst_print_statename(GST_STATE_PENDING(element)));
|
||||
|
||||
if (GST_STATE_TRANSITION(element) == GST_STATE_READY_TO_PLAYING) {
|
||||
if ((GST_STATE_TRANSITION(element) == GST_STATE_READY_TO_PLAYING) ||
|
||||
(GST_STATE_TRANSITION(element) == GST_STATE_PAUSED_TO_PLAYING)) {
|
||||
if (GST_ELEMENT_PARENT(element))
|
||||
fprintf(stderr,"READY->PLAYING: element \"%s\" has parent \"%s\" and sched %p\n",
|
||||
GST_ELEMENT_NAME(element),GST_ELEMENT_NAME(GST_ELEMENT_PARENT(element)),GST_ELEMENT_SCHED(element));
|
||||
GST_SCHEDULE_ENABLE_ELEMENT (element->sched,element);
|
||||
}
|
||||
else if (GST_STATE_TRANSITION(element) == GST_STATE_PLAYING_TO_READY)
|
||||
else if ((GST_STATE_TRANSITION(element) == GST_STATE_PLAYING_TO_READY) ||
|
||||
(GST_STATE_TRANSITION(element) == GST_STATE_PLAYING_TO_READY))
|
||||
GST_SCHEDULE_DISABLE_ELEMENT (element->sched,element);
|
||||
|
||||
GST_STATE (element) = GST_STATE_PENDING (element);
|
||||
|
|
|
@ -1130,13 +1130,12 @@ gst_schedule_pad_disconnect (GstSchedule *sched, GstPad *srcpad, GstPad *sinkpad
|
|||
GstElement *element1, *element2;
|
||||
GstScheduleChain *chain1, *chain2;
|
||||
|
||||
GST_INFO (GST_CAT_SCHEDULING, "have pad disconnected callback on %s:%s",GST_DEBUG_PAD_NAME(srcpad));
|
||||
GST_INFO (GST_CAT_SCHEDULING, "disconnecting pads %s:%s and %s:%s",
|
||||
GST_DEBUG_PAD_NAME(srcpad), GST_DEBUG_PAD_NAME(sinkpad));
|
||||
|
||||
// we need to have the parent elements of each pad
|
||||
element1 = GST_ELEMENT(GST_PAD_PARENT(srcpad));
|
||||
element2 = GST_ELEMENT(GST_PAD_PARENT(sinkpad));
|
||||
GST_INFO (GST_CAT_SCHEDULING, "disconnecting elements \"%s\" and \"%s\"",
|
||||
GST_ELEMENT_NAME(element1), GST_ELEMENT_NAME(element2));
|
||||
|
||||
// first task is to remove the old chain they belonged to.
|
||||
// this can be accomplished by taking either of the elements,
|
||||
|
|
Loading…
Reference in a new issue