From f1318291ed849c527d0dc2a8c8a9bd1f5fbd4aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 6 Jul 2006 13:04:24 +0000 Subject: [PATCH] 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. --- ChangeLog | 12 ++++++++++++ gst/playback/gstplaybasebin.c | 15 +++++++++------ gst/playback/gstplaybasebin.h | 4 +++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e114836262..5dccf2a7c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-07-06 Tim-Philipp Müller + + * 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 * win32/common/libgsttag.def: diff --git a/gst/playback/gstplaybasebin.c b/gst/playback/gstplaybasebin.c index 003e10d72f..bd410b973b 100644 --- a/gst/playback/gstplaybasebin.c +++ b/gst/playback/gstplaybasebin.c @@ -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 diff --git a/gst/playback/gstplaybasebin.h b/gst/playback/gstplaybasebin.h index 3110157965..e253002615 100644 --- a/gst/playback/gstplaybasebin.h +++ b/gst/playback/gstplaybasebin.h @@ -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 */