only open/close library during state changes, not creation/disposal

Original commit message from CVS:
only open/close library during state changes, not creation/disposal
This commit is contained in:
Thomas Vander Stichele 2004-04-13 12:17:21 +00:00
parent 178b620bc7
commit cd532be410
2 changed files with 33 additions and 27 deletions

View file

@ -1,7 +1,17 @@
2004-04-13 Thomas Vander Stichele <thomas at apestaart dot org>
* ext/libcaca/gstcacasink.c: (gst_cacasink_class_init),
(gst_cacasink_sinkconnect), (gst_cacasink_init),
(gst_cacasink_chain), (gst_cacasink_open), (gst_cacasink_close):
init/end library during state transition, not object
creation/disposal. get rid of custom dispose handler.
2004-04-12 Christian Schaller <Uraeus@gnome.org>
* sys/oss/gstosselement.c: s/lstat/stat/ from freeBSD, since it can
be a symlink
2004-04-11 Ronald Bultje <rbultje@ronald.bitfreak.net>
* gst/avi/gstavidemux.c: (gst_avi_demux_stream_data):

View file

@ -74,7 +74,6 @@ static void gst_cacasink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_cacasink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_cacasink_dispose (GObject * object);
static GstElementStateReturn gst_cacasink_change_state (GstElement * element);
@ -188,7 +187,6 @@ gst_cacasink_class_init (GstCACASinkClass * klass)
gobject_class->set_property = gst_cacasink_set_property;
gobject_class->get_property = gst_cacasink_get_property;
gobject_class->dispose = gst_cacasink_dispose;
gstelement_class->change_state = gst_cacasink_change_state;
}
@ -239,6 +237,9 @@ gst_cacasink_sinkconnect (GstPad * pad, const GstCaps * caps)
cacasink = GST_CACASINK (gst_pad_get_parent (pad));
/* We cannot use library functions if the sink is not open */
if (!GST_FLAG_IS_SET (GST_ELEMENT (cacasink), GST_CACASINK_OPEN))
return GST_PAD_LINK_DELAYED;
/*if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED; */
@ -304,16 +305,6 @@ gst_cacasink_init (GstCACASink * cacasink)
cacasink->green_mask = GST_CACA_DEFAULT_GREEN_MASK;
cacasink->blue_mask = GST_CACA_DEFAULT_BLUE_MASK;
cacasink->bitmap = NULL;
caca_init ();
cacasink->screen_width = caca_get_width ();
cacasink->screen_height = caca_get_height ();
cacasink->antialiasing = TRUE;
caca_set_feature (CACA_ANTIALIASING_MAX);
cacasink->dither = 0;
caca_set_dithering (CACA_DITHERING_NONE);
GST_FLAG_SET (cacasink, GST_ELEMENT_THREAD_SUGGESTED);
}
@ -330,6 +321,9 @@ gst_cacasink_chain (GstPad * pad, GstData * _data)
g_return_if_fail (buf != NULL);
cacasink = GST_CACASINK (gst_pad_get_parent (pad));
/* We cannot use library functions if the sink is not open */
if (!GST_FLAG_IS_SET (GST_ELEMENT (cacasink), GST_CACASINK_OPEN))
return;
if (cacasink->id && GST_CLOCK_TIME_IS_VALID (time)) {
GST_DEBUG ("videosink: clock %s wait: %" G_GUINT64_FORMAT " %u",
@ -353,21 +347,6 @@ gst_cacasink_chain (GstPad * pad, GstData * _data)
gst_buffer_unref (buf);
}
static void
gst_cacasink_dispose (GObject * object)
{
GstCACASink *cacasink = GST_CACASINK (object);
if (cacasink->bitmap) {
caca_free_bitmap (cacasink->bitmap);
}
caca_end ();
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_cacasink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@ -439,6 +418,17 @@ gst_cacasink_open (GstCACASink * cacasink)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (cacasink, GST_CACASINK_OPEN), FALSE);
cacasink->bitmap = NULL;
caca_init ();
cacasink->screen_width = caca_get_width ();
cacasink->screen_height = caca_get_height ();
cacasink->antialiasing = TRUE;
caca_set_feature (CACA_ANTIALIASING_MAX);
cacasink->dither = 0;
caca_set_dithering (CACA_DITHERING_NONE);
GST_FLAG_SET (cacasink, GST_CACASINK_OPEN);
return TRUE;
@ -449,6 +439,12 @@ gst_cacasink_close (GstCACASink * cacasink)
{
g_return_if_fail (GST_FLAG_IS_SET (cacasink, GST_CACASINK_OPEN));
if (cacasink->bitmap) {
caca_free_bitmap (cacasink->bitmap);
cacasink->bitmap = NULL;
}
caca_end ();
GST_FLAG_UNSET (cacasink, GST_CACASINK_OPEN);
}