[clutter-gst] video-player: Actually implement clutter_gst_player_deinit()
- From: Damien Lespiau <dlespiau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter-gst] video-player: Actually implement clutter_gst_player_deinit()
- Date: Tue, 30 Aug 2011 14:18:52 +0000 (UTC)
commit ab30a2b758d3635b550958e2b95847b7a800a080
Author: Damien Lespiau <damien lespiau intel com>
Date: Tue Aug 30 15:17:04 2011 +0100
video-player: Actually implement clutter_gst_player_deinit()
When ClutterGstPlayer has been split out, the deinit() code was
forgotten. It's back in with test-video-texture-new-unref-loop showing 0
leak. Yeah!
clutter-gst/clutter-gst-player.c | 68 +++++++++++++++++++++---------
clutter-gst/clutter-gst-player.h | 1 +
clutter-gst/clutter-gst-video-texture.c | 2 +
doc/reference/clutter-gst-sections.txt | 1 +
4 files changed, 51 insertions(+), 21 deletions(-)
---
diff --git a/clutter-gst/clutter-gst-player.c b/clutter-gst/clutter-gst-player.c
index 9ee06db..944cf92 100644
--- a/clutter-gst/clutter-gst-player.c
+++ b/clutter-gst/clutter-gst-player.c
@@ -121,7 +121,6 @@ struct _ClutterGstPlayerIfacePrivate
guint property_id,
GValue *value,
GParamSpec *pspec);
- void (*dispose) (GObject *object);
};
typedef struct _ClutterGstPlayerPrivate ClutterGstPlayerPrivate;
@@ -1348,23 +1347,6 @@ on_current_text_changed (GstElement *pipeline,
/* GObject's magic/madness */
static void
-clutter_gst_player_deinit (ClutterGstPlayer *player)
-{
- /* TODO */
-}
-
-static void
-clutter_gst_player_dispose (GObject *object)
-{
- ClutterGstPlayer *player = CLUTTER_GST_PLAYER (object);
- ClutterGstPlayerIfacePrivate *iface_priv = PLAYER_GET_CLASS_PRIVATE (object);
-
- clutter_gst_player_deinit (player);
-
- iface_priv->dispose (object);
-}
-
-static void
clutter_gst_player_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -1535,7 +1517,7 @@ clutter_gst_player_get_property (GObject *object,
* @object_class: a #GObjectClass
*
* Adds the #ClutterGstPlayer properties to a class and surchages the
- * set/get_property and dispose of #GObjectClass. You should call this
+ * set/get_property of #GObjectClass. You should call this
* function at the end of the class_init method of the class
* implementing #ClutterGstPlayer.
*
@@ -1554,10 +1536,8 @@ clutter_gst_player_class_init (GObjectClass *object_class)
/* Save object's methods we want to override */
priv->set_property = object_class->set_property;
priv->get_property = object_class->get_property;
- priv->dispose = object_class->dispose;
/* Replace by our methods */
- object_class->dispose = clutter_gst_player_dispose;
object_class->set_property = clutter_gst_player_set_property;
object_class->get_property = clutter_gst_player_get_property;
@@ -1645,6 +1625,10 @@ get_pipeline (void)
* function at the beginning of the init method of the class
* implementing #ClutterGstPlayer.
*
+ * When you're finished with the ClutterGstPlayer mixin features (usually in
+ * the dispose or finalize vfuncs), call clutter_gst_player_deinit() to
+ * desallocate the resources created by clutter_gst_player_init().
+ *
* Return value: TRUE if the initialization was successfull, FALSE otherwise.
*
* Since: 1.4
@@ -1736,6 +1720,48 @@ clutter_gst_player_init (ClutterGstPlayer *player)
return TRUE;
}
+/**
+ * clutter_gst_player_deinit:
+ * @player: a #ClutterGstPlayer
+ *
+ * Frees the resources created by clutter_gst_player_init(). After
+ * clutter_gst_player_deinit() has been called, no other player method can be
+ * called on the instance.
+ *
+ * Since: 1.4
+ */
+void
+clutter_gst_player_deinit (ClutterGstPlayer *player)
+{
+ ClutterGstPlayerPrivate *priv;
+
+ g_return_if_fail (CLUTTER_GST_IS_PLAYER (player));
+
+ priv = PLAYER_GET_PRIVATE (player);
+
+ /* start by doing the usual clean up when not wanting to play an URI */
+ set_uri (player, NULL);
+
+ if (priv->bus)
+ {
+ gst_bus_remove_signal_watch (priv->bus);
+ priv->bus = NULL;
+ }
+
+ if (priv->pipeline)
+ {
+ gst_object_unref (GST_OBJECT (priv->pipeline));
+ priv->pipeline = NULL;
+ }
+
+ g_free (priv->uri);
+ g_free (priv->font_name);
+ free_string_list (&priv->audio_streams);
+ free_string_list (&priv->subtitle_tracks);
+
+ g_slice_free (ClutterGstPlayerPrivate, priv);
+}
+
static void
clutter_gst_player_default_init (ClutterGstPlayerIface *iface)
{
diff --git a/clutter-gst/clutter-gst-player.h b/clutter-gst/clutter-gst-player.h
index 91fa55c..bee442c 100644
--- a/clutter-gst/clutter-gst-player.h
+++ b/clutter-gst/clutter-gst-player.h
@@ -97,6 +97,7 @@ GType clutter_gst_player_get_type (void) G_GNUC_CONST;
void clutter_gst_player_class_init (GObjectClass *object_class);
gboolean clutter_gst_player_init (ClutterGstPlayer *player);
+void clutter_gst_player_deinit (ClutterGstPlayer *player);
GstElement * clutter_gst_player_get_pipeline (ClutterGstPlayer *player);
diff --git a/clutter-gst/clutter-gst-video-texture.c b/clutter-gst/clutter-gst-video-texture.c
index 0ec9cbf..f7193c0 100644
--- a/clutter-gst/clutter-gst-video-texture.c
+++ b/clutter-gst/clutter-gst-video-texture.c
@@ -420,6 +420,8 @@ clutter_gst_video_texture_finalize (GObject *object)
self = CLUTTER_GST_VIDEO_TEXTURE (object);
priv = self->priv;
+ clutter_gst_player_deinit (CLUTTER_GST_PLAYER (self));
+
if (priv->idle_material != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->idle_material);
diff --git a/doc/reference/clutter-gst-sections.txt b/doc/reference/clutter-gst-sections.txt
index bd7a710..3c2fef8 100644
--- a/doc/reference/clutter-gst-sections.txt
+++ b/doc/reference/clutter-gst-sections.txt
@@ -17,6 +17,7 @@ ClutterGstPlayer
ClutterGstPlayerIface
clutter_gst_player_class_init
clutter_gst_player_init
+clutter_gst_player_deinit
clutter_gst_player_get_pipeline
clutter_gst_player_get_idle
clutter_gst_player_get_user_agent
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]