ext/gconf/: Ignore changing the GConf key to "". Ignore GConf key updates that don't actually change the string.

Original commit message from CVS:
* ext/gconf/gconf.c: (gst_gconf_get_default_audio_sink),
(gst_gconf_get_default_video_sink),
(gst_gconf_get_default_audio_src),
(gst_gconf_get_default_video_src):
* ext/gconf/gconf.h:
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_reset),
(gst_gconf_audio_sink_init), (gst_gconf_audio_sink_dispose),
(do_toggle_element):
* ext/gconf/gstgconfaudiosink.h:
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_reset),
(gst_gconf_audio_src_init), (gst_gconf_audio_src_dispose),
(do_toggle_element):
* ext/gconf/gstgconfaudiosrc.h:
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_reset),
(gst_gconf_video_sink_init), (gst_gconf_video_sink_dispose),
(do_toggle_element):
* ext/gconf/gstgconfvideosink.h:
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_reset),
(gst_gconf_video_src_init), (gst_gconf_video_src_dispose),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.h:
Ignore changing the GConf key to "". Ignore GConf key updates
that don't actually change the string.
For now, ignore the GConf key when the state is > READY, as
it breaks streaming. Sometime it will be nice to bring the
new sink online even mid-stream, by sending NEWSEGMENT info
and possibly prerolling.
(Fixes #326736)
This commit is contained in:
Jan Schmidt 2006-02-05 22:22:56 +00:00
parent 07c1dceae0
commit 059527abc0
11 changed files with 185 additions and 8 deletions

View file

@ -1,3 +1,34 @@
2006-02-05 Jan Schmidt <thaytan@mad.scientist.com>
* ext/gconf/gconf.c: (gst_gconf_get_default_audio_sink),
(gst_gconf_get_default_video_sink),
(gst_gconf_get_default_audio_src),
(gst_gconf_get_default_video_src):
* ext/gconf/gconf.h:
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_reset),
(gst_gconf_audio_sink_init), (gst_gconf_audio_sink_dispose),
(do_toggle_element):
* ext/gconf/gstgconfaudiosink.h:
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_reset),
(gst_gconf_audio_src_init), (gst_gconf_audio_src_dispose),
(do_toggle_element):
* ext/gconf/gstgconfaudiosrc.h:
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_reset),
(gst_gconf_video_sink_init), (gst_gconf_video_sink_dispose),
(do_toggle_element):
* ext/gconf/gstgconfvideosink.h:
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_reset),
(gst_gconf_video_src_init), (gst_gconf_video_src_dispose),
(do_toggle_element):
* ext/gconf/gstgconfvideosrc.h:
Ignore changing the GConf key to "". Ignore GConf key updates
that don't actually change the string.
For now, ignore the GConf key when the state is > READY, as
it breaks streaming. Sometime it will be nice to bring the
new sink online even mid-stream, by sending NEWSEGMENT info
and possibly prerolling.
(Fixes #326736)
2006-02-05 Jan Schmidt <thaytan@mad.scientist.com>
* gst/goom/filters.c: (zoomFilterNew), (calculatePXandPY),

View file

@ -139,7 +139,7 @@ gst_gconf_render_bin_from_key (const gchar * key)
GstElement *
gst_gconf_get_default_audio_sink (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/audiosink");
GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_AUDIOSINK_KEY);
if (!ret) {
ret = gst_element_factory_make (DEFAULT_AUDIOSINK, NULL);
@ -165,7 +165,7 @@ gst_gconf_get_default_audio_sink (void)
GstElement *
gst_gconf_get_default_video_sink (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/videosink");
GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSINK_KEY);
if (!ret) {
ret = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL);
@ -191,7 +191,7 @@ gst_gconf_get_default_video_sink (void)
GstElement *
gst_gconf_get_default_audio_src (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/audiosrc");
GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_AUDIOSRC_KEY);
if (!ret) {
ret = gst_element_factory_make (DEFAULT_AUDIOSRC, NULL);
@ -217,7 +217,7 @@ gst_gconf_get_default_audio_src (void)
GstElement *
gst_gconf_get_default_video_src (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/videosrc");
GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSRC_KEY);
if (!ret) {
ret = gst_element_factory_make (DEFAULT_VIDEOSRC, NULL);

View file

@ -29,6 +29,11 @@
G_BEGIN_DECLS
#define GST_GCONF_AUDIOSRC_KEY "default/audiosrc"
#define GST_GCONF_AUDIOSINK_KEY "default/audiosink"
#define GST_GCONF_VIDEOSRC_KEY "default/videosrc"
#define GST_GCONF_VIDEOSINK_KEY "default/videosink"
gchar * gst_gconf_get_string (const gchar *key);
void gst_gconf_set_string (const gchar *key,
const gchar *value);

View file

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <string.h>
#include "gstgconfelements.h"
#include "gstgconfaudiosink.h"
@ -83,6 +85,9 @@ gst_gconf_audio_sink_reset (GstGConfAudioSink * sink)
targetpad = gst_element_get_pad (sink->kid, "sink");
gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
gst_object_unref (targetpad);
g_free (sink->gconf_str);
sink->gconf_str = NULL;
}
static void
@ -97,7 +102,8 @@ gst_gconf_audio_sink_init (GstGConfAudioSink * sink,
sink->client = gconf_client_get_default ();
gconf_client_add_dir (sink->client, GST_GCONF_DIR,
GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
gconf_client_notify_add (sink->client, GST_GCONF_DIR "/default/audiosink",
gconf_client_notify_add (sink->client,
GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY,
cb_toggle_element, sink, NULL, NULL);
}
@ -111,6 +117,9 @@ gst_gconf_audio_sink_dispose (GObject * object)
sink->client = NULL;
}
g_free (sink->gconf_str);
sink->gconf_str = NULL;
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
@ -118,6 +127,37 @@ static gboolean
do_toggle_element (GstGConfAudioSink * sink)
{
GstPad *targetpad;
gchar *new_gconf_str;
GstState cur, next;
new_gconf_str = gst_gconf_get_string (GST_GCONF_AUDIOSINK_KEY);
if (new_gconf_str != NULL && sink->gconf_str != NULL &&
(strlen (new_gconf_str) == 0 ||
strcmp (sink->gconf_str, new_gconf_str) == 0)) {
g_free (new_gconf_str);
GST_DEBUG_OBJECT (sink, "GConf key was updated, but it didn't change");
return TRUE;
}
/* Sometime, it would be lovely to allow sink changes even when
* already running, but this involves sending an appropriate new-segment
* and possibly prerolling etc */
GST_OBJECT_LOCK (sink);
cur = GST_STATE (sink);
next = GST_STATE_PENDING (sink);
GST_OBJECT_UNLOCK (sink);
if (cur > GST_STATE_READY || next == GST_STATE_PAUSED) {
GST_DEBUG_OBJECT (sink,
"Auto-sink is already running. Ignoring GConf change");
return TRUE;
}
GST_DEBUG_OBJECT (sink, "GConf key changed: '%s' to '%s'",
GST_STR_NULL (sink->gconf_str), GST_STR_NULL (new_gconf_str));
g_free (sink->gconf_str);
sink->gconf_str = new_gconf_str;
/* kill old element */
if (sink->kid) {
@ -131,6 +171,8 @@ do_toggle_element (GstGConfAudioSink * sink)
if (!(sink->kid = gst_gconf_get_default_audio_sink ())) {
GST_ELEMENT_ERROR (sink, LIBRARY, SETTINGS, (NULL),
("Failed to render audio sink from GConf"));
g_free (sink->gconf_str);
sink->gconf_str = NULL;
return FALSE;
}
gst_element_set_state (sink->kid, GST_STATE (sink));

View file

@ -45,6 +45,9 @@ typedef struct _GstGConfAudioSink {
GConfClient *client;
GstElement *kid;
GstPad *pad;
/* Current gconf string */
gchar *gconf_str;
} GstGConfAudioSink;
typedef struct _GstGConfAudioSinkClass {

View file

@ -22,6 +22,8 @@
#include "config.h"
#endif
#include <string.h>
#include "gstgconfelements.h"
#include "gstgconfaudiosrc.h"
@ -84,6 +86,9 @@ gst_gconf_audio_src_reset (GstGConfAudioSrc * src)
targetpad = gst_element_get_pad (src->kid, "src");
gst_ghost_pad_set_target (GST_GHOST_PAD (src->pad), targetpad);
gst_object_unref (targetpad);
g_free (src->gconf_str);
src->gconf_str = NULL;
}
static void
@ -98,7 +103,8 @@ 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, GST_GCONF_DIR "/default/audiosrc",
gconf_client_notify_add (src->client,
GST_GCONF_DIR "/" GST_GCONF_AUDIOSRC_KEY,
cb_toggle_element, src, NULL, NULL);
}
@ -112,6 +118,9 @@ gst_gconf_audio_src_dispose (GObject * object)
src->client = NULL;
}
g_free (src->gconf_str);
src->gconf_str = NULL;
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
@ -119,6 +128,19 @@ static gboolean
do_toggle_element (GstGConfAudioSrc * src)
{
GstPad *targetpad;
gchar *new_gconf_str;
new_gconf_str = gst_gconf_get_string (GST_GCONF_AUDIOSRC_KEY);
if (new_gconf_str != NULL && src->gconf_str != NULL &&
(strlen (new_gconf_str) == 0 ||
strcmp (src->gconf_str, new_gconf_str) == 0)) {
g_free (new_gconf_str);
GST_DEBUG_OBJECT (src, "GConf key was updated, but it didn't change");
return TRUE;
}
g_free (src->gconf_str);
src->gconf_str = new_gconf_str;
/* kill old element */
if (src->kid) {
@ -132,6 +154,8 @@ do_toggle_element (GstGConfAudioSrc * src)
if (!(src->kid = gst_gconf_get_default_audio_src ())) {
GST_ELEMENT_ERROR (src, LIBRARY, SETTINGS, (NULL),
("Failed to render audio source from GConf"));
g_free (src->gconf_str);
src->gconf_str = NULL;
return FALSE;
}
gst_element_set_state (src->kid, GST_STATE (src));

View file

@ -39,6 +39,9 @@ typedef struct _GstGConfAudioSrc {
GConfClient *client;
GstElement *kid;
GstPad *pad;
/* Current gconf string */
gchar *gconf_str;
} GstGConfAudioSrc;
typedef struct _GstGConfAudioSrcClass {

View file

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <string.h>
#include "gstgconfelements.h"
#include "gstgconfvideosink.h"
@ -83,6 +85,9 @@ gst_gconf_video_sink_reset (GstGConfVideoSink * sink)
targetpad = gst_element_get_pad (sink->kid, "sink");
gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad);
gst_object_unref (targetpad);
g_free (sink->gconf_str);
sink->gconf_str = NULL;
}
static void
@ -97,7 +102,8 @@ gst_gconf_video_sink_init (GstGConfVideoSink * sink,
sink->client = gconf_client_get_default ();
gconf_client_add_dir (sink->client, GST_GCONF_DIR,
GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
gconf_client_notify_add (sink->client, GST_GCONF_DIR "/default/videosink",
gconf_client_notify_add (sink->client,
GST_GCONF_DIR "/" GST_GCONF_VIDEOSINK_KEY,
cb_toggle_element, sink, NULL, NULL);
}
@ -110,6 +116,8 @@ gst_gconf_video_sink_dispose (GObject * object)
g_object_unref (G_OBJECT (sink->client));
sink->client = NULL;
}
g_free (sink->gconf_str);
sink->gconf_str = NULL;
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
@ -118,6 +126,37 @@ static gboolean
do_toggle_element (GstGConfVideoSink * sink)
{
GstPad *targetpad;
gchar *new_gconf_str;
GstState cur, next;
new_gconf_str = gst_gconf_get_string (GST_GCONF_VIDEOSINK_KEY);
if (new_gconf_str != NULL && sink->gconf_str != NULL &&
(strlen (new_gconf_str) == 0 ||
strcmp (sink->gconf_str, new_gconf_str) == 0)) {
g_free (new_gconf_str);
GST_DEBUG_OBJECT (sink, "GConf key was updated, but it didn't change");
return TRUE;
}
/* Sometime, it would be lovely to allow sink changes even when
* already running, but this involves sending an appropriate new-segment
* and possibly prerolling etc */
GST_OBJECT_LOCK (sink);
cur = GST_STATE (sink);
next = GST_STATE_PENDING (sink);
GST_OBJECT_UNLOCK (sink);
if (cur > GST_STATE_READY || next == GST_STATE_PAUSED) {
GST_DEBUG_OBJECT (sink,
"Auto-sink is already running. Ignoring GConf change");
return TRUE;
}
GST_DEBUG_OBJECT (sink, "GConf key changed: '%s' to '%s'",
GST_STR_NULL (sink->gconf_str), GST_STR_NULL (new_gconf_str));
g_free (sink->gconf_str);
sink->gconf_str = new_gconf_str;
/* kill old element */
if (sink->kid) {

View file

@ -45,6 +45,9 @@ typedef struct _GstGConfVideoSink {
GConfClient *client;
GstElement *kid;
GstPad *pad;
/* Current gconf string */
gchar *gconf_str;
} GstGConfVideoSink;
typedef struct _GstGConfVideoSinkClass {

View file

@ -22,6 +22,8 @@
#include "config.h"
#endif
#include <string.h>
#include "gstgconfelements.h"
#include "gstgconfvideosrc.h"
@ -84,6 +86,9 @@ gst_gconf_video_src_reset (GstGConfVideoSrc * src)
targetpad = gst_element_get_pad (src->kid, "src");
gst_ghost_pad_set_target (GST_GHOST_PAD (src->pad), targetpad);
gst_object_unref (targetpad);
g_free (src->gconf_str);
src->gconf_str = NULL;
}
static void
@ -98,7 +103,8 @@ gst_gconf_video_src_init (GstGConfVideoSrc * 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, GST_GCONF_DIR "/default/videosrc",
gconf_client_notify_add (src->client,
GST_GCONF_DIR "/" GST_GCONF_VIDEOSRC_KEY,
cb_toggle_element, src, NULL, NULL);
}
@ -112,6 +118,9 @@ gst_gconf_video_src_dispose (GObject * object)
src->client = NULL;
}
g_free (src->gconf_str);
src->gconf_str = NULL;
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
@ -119,6 +128,19 @@ static gboolean
do_toggle_element (GstGConfVideoSrc * src)
{
GstPad *targetpad;
gchar *new_gconf_str;
new_gconf_str = gst_gconf_get_string (GST_GCONF_AUDIOSRC_KEY);
if (new_gconf_str != NULL && src->gconf_str != NULL &&
(strlen (new_gconf_str) == 0 ||
strcmp (src->gconf_str, new_gconf_str) == 0)) {
g_free (new_gconf_str);
GST_DEBUG_OBJECT (src, "GConf key was updated, but it didn't change");
return TRUE;
}
g_free (src->gconf_str);
src->gconf_str = new_gconf_str;
/* kill old element */
if (src->kid) {
@ -132,6 +154,8 @@ do_toggle_element (GstGConfVideoSrc * src)
if (!(src->kid = gst_gconf_get_default_video_src ())) {
GST_ELEMENT_ERROR (src, LIBRARY, SETTINGS, (NULL),
("Failed to render video source from GConf"));
g_free (src->gconf_str);
src->gconf_str = NULL;
return FALSE;
}
gst_element_set_state (src->kid, GST_STATE (src));

View file

@ -39,6 +39,9 @@ typedef struct _GstGConfVideoSrc {
GConfClient *client;
GstElement *kid;
GstPad *pad;
/* Current gconf string */
gchar *gconf_str;
} GstGConfVideoSrc;
typedef struct _GstGConfVideoSrcClass {