GstDecodeChain *decode_chain; /* Top level decode chain */
gint nbpads; /* unique identifier for source pads */
+ GMutex *factories_lock;
guint32 factories_cookie; /* Cookie from last time when factories was updated */
GValueArray *factories; /* factories we can use for selecting elements */
GST_DEBUG_FUNCPTR (gst_decode_bin_change_state);
}
+/* Must be called with factories lock! */
+static void
+gst_decode_bin_update_factories_list (GstDecodeBin * dbin)
+{
+ if (!dbin->factories
+ || 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 ();
+ }
+}
+
static void
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 ();
+ decode_bin->factories_lock = g_mutex_new ();
+ gst_decode_bin_update_factories_list (decode_bin);
/* we create the typefind element only once */
decode_bin->typefind = gst_element_factory_make ("typefind", "typefind");
decode_bin->subtitle_lock = NULL;
}
+ if (decode_bin->factories_lock) {
+ g_mutex_free (decode_bin->factories_lock);
+ decode_bin->factories_lock = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GstCaps * caps)
{
GValueArray *result;
+ GstDecodeBin *dbin = GST_DECODE_BIN_CAST (element);
GST_DEBUG_OBJECT (element, "finding factories");
/* return all compatible factories for caps */
- result =
- gst_factory_list_filter (GST_DECODE_BIN_CAST (element)->factories, caps);
+ g_mutex_lock (dbin->factories_lock);
+ gst_decode_bin_update_factories_list (dbin);
+ result = gst_factory_list_filter (dbin->factories, caps);
+ g_mutex_unlock (dbin->factories_lock);
GST_DEBUG_OBJECT (element, "autoplug-factories returns %p", result);
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 ();
- }
+ g_mutex_lock (dbin->factories_lock);
+ gst_decode_bin_update_factories_list (dbin);
+ g_mutex_unlock (dbin->factories_lock);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
DYN_LOCK (dbin);
/* if we are shutting down or not */
gint shutdown;
+ GMutex *elements_lock;
guint32 elements_cookie;
GValueArray *elements; /* factories we can use for selecting elements */
g_object_notify (G_OBJECT (playbin), "mute");
}
+/* Must be called with elements lock! */
static void
-gst_play_bin_init (GstPlayBin * playbin)
+gst_play_bin_update_elements_list (GstPlayBin * playbin)
{
- GstFactoryListType type;
+ if (!playbin->elements ||
+ 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 |
+ GST_FACTORY_LIST_SINK);
+ playbin->elements_cookie = gst_default_registry_get_feature_list_cookie ();
+ }
+}
+static void
+gst_play_bin_init (GstPlayBin * playbin)
+{
playbin->lock = g_mutex_new ();
playbin->dyn_lock = g_mutex_new ();
init_group (playbin, &playbin->groups[1]);
/* 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 ();
+ playbin->elements_lock = g_mutex_new ();
+ gst_play_bin_update_elements_list (playbin);
gst_factory_list_debug (playbin->elements);
/* add sink */
g_free (playbin->encoding);
g_mutex_free (playbin->lock);
g_mutex_free (playbin->dyn_lock);
+ g_mutex_free (playbin->elements_lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
group, GST_DEBUG_PAD_NAME (pad), caps);
/* filter out the elements based on the caps. */
+ g_mutex_lock (playbin->elements_lock);
+ gst_play_bin_update_elements_list (playbin);
result = gst_factory_list_filter (playbin->elements, caps);
+ g_mutex_unlock (playbin->elements_lock);
GST_DEBUG_OBJECT (playbin, "found factories %p", result);
gst_factory_list_debug (result);
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 ();
- }
+ g_mutex_lock (playbin->elements_lock);
+ gst_play_bin_update_elements_list (playbin);
+ g_mutex_unlock (playbin->elements_lock);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_LOG_OBJECT (playbin, "clearing shutdown flag");
GMutex *lock; /* lock for constructing */
+ GMutex *factories_lock;
guint32 factories_cookie;
GValueArray *factories; /* factories we can use for selecting elements */
return TRUE;
}
+/* Must be called with factories lock! */
+static void
+gst_uri_decode_bin_update_factories_list (GstURIDecodeBin * dec)
+{
+ if (!dec->factories ||
+ dec->factories_cookie !=
+ gst_default_registry_get_feature_list_cookie ()) {
+ if (dec->factories)
+ g_value_array_free (dec->factories);
+ dec->factories = gst_factory_list_get_elements (GST_FACTORY_LIST_DECODER);
+ dec->factories_cookie = gst_default_registry_get_feature_list_cookie ();
+ }
+}
+
static GValueArray *
gst_uri_decode_bin_autoplug_factories (GstElement * element, GstPad * pad,
GstCaps * caps)
{
GValueArray *result;
+ GstURIDecodeBin *dec = GST_URI_DECODE_BIN_CAST (element);
GST_DEBUG_OBJECT (element, "finding factories");
/* return all compatible factories for caps */
- result =
- gst_factory_list_filter (GST_URI_DECODE_BIN_CAST (element)->factories,
- caps);
+ g_mutex_lock (dec->factories_lock);
+ gst_uri_decode_bin_update_factories_list (dec);
+ result = gst_factory_list_filter (dec->factories, caps);
+ g_mutex_unlock (dec->factories_lock);
GST_DEBUG_OBJECT (element, "autoplug-factories returns %p", result);
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->factories_lock = g_mutex_new ();
+ gst_uri_decode_bin_update_factories_list (dec);
dec->lock = g_mutex_new ();
remove_decoders (dec, TRUE);
g_mutex_free (dec->lock);
+ g_mutex_free (dec->factories_lock);
g_free (dec->uri);
g_free (dec->encoding);
if (dec->factories)
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 ();
- }
+ g_mutex_lock (decoder->factories_lock);
+ gst_uri_decode_bin_update_factories_list (decoder);
+ g_mutex_unlock (decoder->factories_lock);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!setup_source (decoder))