Commit 2f992c78 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠
Browse files

ext/gconf/gstgconfaudiosrc.*: Remove gconf notify hook when the gconfaudiosrc...

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.
parent 14999998
2006-12-11 Tim-Philipp Müller <tim at centricular dot net>
* 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.
2006-12-09 Tim-Philipp Müller <tim at centricular dot net> 2006-12-09 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Sebastian Dröge <mail at slomosnail de> Patch by: Sebastian Dröge <mail at slomosnail de>
......
...@@ -102,7 +102,7 @@ gst_gconf_audio_src_init (GstGConfAudioSrc * src, ...@@ -102,7 +102,7 @@ gst_gconf_audio_src_init (GstGConfAudioSrc * src,
src->client = gconf_client_get_default (); src->client = gconf_client_get_default ();
gconf_client_add_dir (src->client, GST_GCONF_DIR, gconf_client_add_dir (src->client, GST_GCONF_DIR,
GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); 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, GST_GCONF_DIR "/" GST_GCONF_AUDIOSRC_KEY,
cb_toggle_element, src, NULL, NULL); cb_toggle_element, src, NULL, NULL);
} }
...@@ -113,6 +113,11 @@ gst_gconf_audio_src_dispose (GObject * object) ...@@ -113,6 +113,11 @@ gst_gconf_audio_src_dispose (GObject * object)
GstGConfAudioSrc *src = GST_GCONF_AUDIO_SRC (object); GstGConfAudioSrc *src = GST_GCONF_AUDIO_SRC (object);
if (src->client) { 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)); g_object_unref (G_OBJECT (src->client));
src->client = NULL; src->client = NULL;
} }
...@@ -126,6 +131,7 @@ gst_gconf_audio_src_dispose (GObject * object) ...@@ -126,6 +131,7 @@ gst_gconf_audio_src_dispose (GObject * object)
static gboolean static gboolean
do_toggle_element (GstGConfAudioSrc * src) do_toggle_element (GstGConfAudioSrc * src)
{ {
GstState cur, next;
GstPad *targetpad; GstPad *targetpad;
gchar *new_gconf_str; gchar *new_gconf_str;
...@@ -138,6 +144,19 @@ do_toggle_element (GstGConfAudioSrc * src) ...@@ -138,6 +144,19 @@ do_toggle_element (GstGConfAudioSrc * src)
return TRUE; 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); g_free (src->gconf_str);
src->gconf_str = new_gconf_str; src->gconf_str = new_gconf_str;
......
...@@ -40,6 +40,8 @@ typedef struct _GstGConfAudioSrc { ...@@ -40,6 +40,8 @@ typedef struct _GstGConfAudioSrc {
GstElement *kid; GstElement *kid;
GstPad *pad; GstPad *pad;
guint gconf_notify_id;
/* Current gconf string */ /* Current gconf string */
gchar *gconf_str; gchar *gconf_str;
} GstGConfAudioSrc; } GstGConfAudioSrc;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment