From ab96265c57229103795e62da2c14510d14802de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Nov 2009 18:13:25 +0100 Subject: [PATCH] playback: When going from NULL->READY check if the registry has new features This makes it possible to use newly installed plugins after going back to NULL instead of requiring a new instance. Fixes bug #599266. --- gst/playback/gstdecodebin2.c | 12 ++++++++++++ gst/playback/gstplaybin2.c | 13 +++++++++++++ gst/playback/gsturidecodebin.c | 13 +++++++++++++ 3 files changed, 38 insertions(+) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 69f5e97f8f..624d27e3ac 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -149,6 +149,7 @@ struct _GstDecodeBin GstDecodeChain *decode_chain; /* Top level decode chain */ gint nbpads; /* unique identifier for source pads */ + guint32 factories_cookie; /* Cookie from last time when factories was updated */ GValueArray *factories; /* factories we can use for selecting elements */ GMutex *subtitle_lock; /* Protects changes to subtitles and encoding */ @@ -845,6 +846,8 @@ gst_decode_bin_init (GstDecodeBin * decode_bin) /* first filter out the interesting element factories */ decode_bin->factories = gst_factory_list_get_elements (GST_FACTORY_LIST_DECODER); + decode_bin->factories_cookie = + gst_default_registry_get_feature_list_cookie (); /* we create the typefind element only once */ decode_bin->typefind = gst_element_factory_make ("typefind", "typefind"); @@ -3229,6 +3232,15 @@ gst_decode_bin_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_NULL_TO_READY: if (dbin->typefind == NULL) goto missing_typefind; + if (dbin->factories_cookie != + gst_default_registry_get_feature_list_cookie ()) { + if (dbin->factories) + g_value_array_free (dbin->factories); + dbin->factories = + gst_factory_list_get_elements (GST_FACTORY_LIST_DECODER); + dbin->factories_cookie = + gst_default_registry_get_feature_list_cookie (); + } break; case GST_STATE_CHANGE_READY_TO_PAUSED: DYN_LOCK (dbin); diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index 7ce6e1a5e0..3610b07c88 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -373,6 +373,7 @@ struct _GstPlayBin /* if we are shutting down or not */ gint shutdown; + guint32 elements_cookie; GValueArray *elements; /* factories we can use for selecting elements */ gboolean have_selector; /* set to FALSE when we fail to create an @@ -1122,6 +1123,7 @@ gst_play_bin_init (GstPlayBin * playbin) /* first filter out the interesting element factories */ type = GST_FACTORY_LIST_DECODER | GST_FACTORY_LIST_SINK; playbin->elements = gst_factory_list_get_elements (type); + playbin->elements_cookie = gst_default_registry_get_feature_list_cookie (); gst_factory_list_debug (playbin->elements); /* add sink */ @@ -2962,6 +2964,17 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition) playbin = GST_PLAY_BIN (element); switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + if (playbin->elements_cookie != + gst_default_registry_get_feature_list_cookie ()) { + if (playbin->elements) + g_value_array_free (playbin->elements); + playbin->elements = + gst_factory_list_get_elements (GST_FACTORY_LIST_DECODER); + playbin->elements_cookie = + gst_default_registry_get_feature_list_cookie (); + } + break; case GST_STATE_CHANGE_READY_TO_PAUSED: GST_LOG_OBJECT (playbin, "clearing shutdown flag"); g_atomic_int_set (&playbin->shutdown, 0); diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index bd620a5668..0bbcf611dd 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -68,6 +68,7 @@ struct _GstURIDecodeBin GMutex *lock; /* lock for constructing */ + guint32 factories_cookie; GValueArray *factories; /* factories we can use for selecting elements */ gchar *uri; @@ -471,6 +472,7 @@ gst_uri_decode_bin_init (GstURIDecodeBin * dec, GstURIDecodeBinClass * klass) { /* first filter out the interesting element factories */ dec->factories = gst_factory_list_get_elements (GST_FACTORY_LIST_DECODER); + dec->factories_cookie = gst_default_registry_get_feature_list_cookie (); dec->lock = g_mutex_new (); @@ -2040,6 +2042,17 @@ gst_uri_decode_bin_change_state (GstElement * element, decoder = GST_URI_DECODE_BIN (element); switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + if (decoder->factories_cookie != + gst_default_registry_get_feature_list_cookie ()) { + if (decoder->factories) + g_value_array_free (decoder->factories); + decoder->factories = + gst_factory_list_get_elements (GST_FACTORY_LIST_DECODER); + decoder->factories_cookie = + gst_default_registry_get_feature_list_cookie (); + } + break; case GST_STATE_CHANGE_READY_TO_PAUSED: if (!setup_source (decoder)) goto source_failed;