gst/playback/gstplaybasebin.*: Protect list of elements with a subtitle-encoding property and the subtitle encoding m...

Original commit message from CVS:
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_init),
(gst_play_base_bin_finalize), (decodebin_element_added_cb),
(decodebin_element_removed_cb), (gst_play_base_bin_set_property):
* gst/playback/gstplaybasebin.h:
Protect list of elements with a subtitle-encoding property and
the subtitle encoding member itself with a lock of their own
instead of using the object lock. This prevents a dead-lock in
the element-remove callback in some circumstances when shutting
down playbin.
This commit is contained in:
Tim-Philipp Müller 2006-07-06 13:04:24 +00:00
parent 8f89dbc65e
commit f1318291ed
3 changed files with 24 additions and 7 deletions

View file

@ -1,3 +1,15 @@
2006-07-06 Tim-Philipp Müller <tim at centricular dot net>
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_init),
(gst_play_base_bin_finalize), (decodebin_element_added_cb),
(decodebin_element_removed_cb), (gst_play_base_bin_set_property):
* gst/playback/gstplaybasebin.h:
Protect list of elements with a subtitle-encoding property and
the subtitle encoding member itself with a lock of their own
instead of using the object lock. This prevents a dead-lock in
the element-remove callback in some circumstances when shutting
down playbin.
2006-07-05 Sebastien Moutte <sebastien@moutte.net>
* win32/common/libgsttag.def:

View file

@ -217,6 +217,7 @@ gst_play_base_bin_init (GstPlayBaseBin * play_base_bin)
play_base_bin->subtitle = NULL;
play_base_bin->subencoding = NULL;
play_base_bin->subtitle_elements = NULL;
play_base_bin->sub_lock = g_mutex_new ();
play_base_bin->group_lock = g_mutex_new ();
play_base_bin->group_cond = g_cond_new ();
@ -255,6 +256,8 @@ gst_play_base_bin_finalize (GObject * object)
g_mutex_free (play_base_bin->group_lock);
g_cond_free (play_base_bin->group_cond);
g_mutex_free (play_base_bin->sub_lock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -1195,11 +1198,11 @@ decodebin_element_added_cb (GstBin * decodebin, GstElement * element,
return;
}
GST_OBJECT_LOCK (play_base_bin);
g_mutex_lock (play_base_bin->sub_lock);
play_base_bin->subtitle_elements =
g_slist_append (play_base_bin->subtitle_elements, element);
encoding = g_strdup (play_base_bin->subencoding);
GST_OBJECT_UNLOCK (play_base_bin);
g_mutex_unlock (play_base_bin->sub_lock);
set_encoding_element (element, encoding);
g_free (encoding);
@ -1211,10 +1214,10 @@ decodebin_element_removed_cb (GstBin * decodebin, GstElement * element,
{
GstPlayBaseBin *play_base_bin = GST_PLAY_BASE_BIN (data);
GST_OBJECT_LOCK (play_base_bin);
g_mutex_lock (play_base_bin->sub_lock);
play_base_bin->subtitle_elements =
g_slist_remove (play_base_bin->subtitle_elements, element);
GST_OBJECT_UNLOCK (play_base_bin);
g_mutex_unlock (play_base_bin->sub_lock);
}
@ -1923,12 +1926,12 @@ gst_play_base_bin_set_property (GObject * object, guint prop_id,
if (encoding == NULL && play_base_bin->subencoding == NULL)
return;
GST_OBJECT_LOCK (play_base_bin);
g_mutex_lock (play_base_bin->sub_lock);
g_free (play_base_bin->subencoding);
play_base_bin->subencoding = g_strdup (encoding);
list = g_slist_copy (play_base_bin->subtitle_elements);
g_slist_foreach (list, (GFunc) gst_object_ref, NULL);
GST_OBJECT_UNLOCK (play_base_bin);
g_mutex_unlock (play_base_bin->sub_lock);
/* we can't hold a lock when calling g_object_set() on a child, since
* the notify event will trigger GstObject to send a deep-notify event

View file

@ -81,9 +81,11 @@ struct _GstPlayBaseBin {
GstElement *decoder;
GstElement *subtitle; /* additional filesrc ! subparse bin */
gboolean subtitle_done;
gboolean need_rebuild;
GSList *subtitle_elements; /* subtitle elements that have 'subtitle-encoding' property */
gchar *subencoding; /* encoding to propagate to the above subtitle elements */
gboolean need_rebuild;
GMutex *sub_lock; /* protecting subtitle_elements and subencoding members */
/* group management - using own lock */
GMutex *group_lock; /* lock and mutex to signal availability of new group */