diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2006-12-11 11:41:18 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2006-12-11 11:41:18 +0000 |
commit | 2f992c783ef619eabc8baec272bf71c3397051d6 (patch) | |
tree | 9fd31a2a8368cd6e17505cff4c21d74386163628 /ext/gconf | |
parent | 14999998d43450efcb2c9f690c2fa98c0262d017 (diff) |
ext/gconf/gstgconfaudiosrc.*: Remove gconf notify hook when the gconfaudiosrc element is destroyed, otherwise the cal...
Original commit message from CVS:
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_init),
(gst_gconf_audio_src_dispose), (do_toggle_element):
* ext/gconf/gstgconfaudiosrc.h:
Remove gconf notify hook when the gconfaudiosrc element is
destroyed, otherwise the callback may be called on an
already-destroyed instance and bad things happen. Should fix
#378184.
Also ignore gconf key changes when the source is already running.
Diffstat (limited to 'ext/gconf')
-rw-r--r-- | ext/gconf/gstgconfaudiosrc.c | 21 | ||||
-rw-r--r-- | ext/gconf/gstgconfaudiosrc.h | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/ext/gconf/gstgconfaudiosrc.c b/ext/gconf/gstgconfaudiosrc.c index b80c89c6..0203c2e2 100644 --- a/ext/gconf/gstgconfaudiosrc.c +++ b/ext/gconf/gstgconfaudiosrc.c @@ -102,7 +102,7 @@ gst_gconf_audio_src_init (GstGConfAudioSrc * src, src->client = gconf_client_get_default (); gconf_client_add_dir (src->client, GST_GCONF_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - gconf_client_notify_add (src->client, + src->gconf_notify_id = gconf_client_notify_add (src->client, GST_GCONF_DIR "/" GST_GCONF_AUDIOSRC_KEY, cb_toggle_element, src, NULL, NULL); } @@ -113,6 +113,11 @@ gst_gconf_audio_src_dispose (GObject * object) GstGConfAudioSrc *src = GST_GCONF_AUDIO_SRC (object); if (src->client) { + if (src->gconf_notify_id) { + gconf_client_notify_remove (src->client, src->gconf_notify_id); + src->gconf_notify_id = 0; + } + g_object_unref (G_OBJECT (src->client)); src->client = NULL; } @@ -126,6 +131,7 @@ gst_gconf_audio_src_dispose (GObject * object) static gboolean do_toggle_element (GstGConfAudioSrc * src) { + GstState cur, next; GstPad *targetpad; gchar *new_gconf_str; @@ -138,6 +144,19 @@ do_toggle_element (GstGConfAudioSrc * src) return TRUE; } + GST_OBJECT_LOCK (src); + cur = GST_STATE (src); + next = GST_STATE_PENDING (src); + GST_OBJECT_UNLOCK (src); + + if (cur >= GST_STATE_READY || next == GST_STATE_PAUSED) { + GST_DEBUG_OBJECT (src, "already running, ignoring GConf change"); + return TRUE; + } + + GST_DEBUG_OBJECT (src, "GConf key changed: '%s' to '%s'", + GST_STR_NULL (src->gconf_str), GST_STR_NULL (new_gconf_str)); + g_free (src->gconf_str); src->gconf_str = new_gconf_str; diff --git a/ext/gconf/gstgconfaudiosrc.h b/ext/gconf/gstgconfaudiosrc.h index f30717f9..cac4085e 100644 --- a/ext/gconf/gstgconfaudiosrc.h +++ b/ext/gconf/gstgconfaudiosrc.h @@ -40,6 +40,8 @@ typedef struct _GstGConfAudioSrc { GstElement *kid; GstPad *pad; + guint gconf_notify_id; + /* Current gconf string */ gchar *gconf_str; } GstGConfAudioSrc; |