turn GstOMXComponent to a GstMiniObject
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 24 Jul 2018 13:06:01 +0000 (15:06 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 30 Aug 2018 08:59:30 +0000 (10:59 +0200)
Will use it for refcounting.

https://bugzilla.gnome.org/show_bug.cgi?id=796918

omx/gstomx.c
omx/gstomx.h
omx/gstomxaudiodec.c
omx/gstomxaudioenc.c
omx/gstomxaudiosink.c
omx/gstomxvideodec.c
omx/gstomxvideoenc.c

index 0acf413..6096806 100644 (file)
@@ -775,6 +775,10 @@ FillBufferDone (OMX_HANDLETYPE hComponent, OMX_PTR pAppData,
 static OMX_CALLBACKTYPE callbacks =
     { EventHandler, EmptyBufferDone, FillBufferDone };
 
+GST_DEFINE_MINI_OBJECT_TYPE (GstOMXComponent, gst_omx_component);
+
+static void gst_omx_component_free (GstOMXComponent * comp);
+
 /* NOTE: Uses comp->lock and comp->messages_lock */
 GstOMXComponent *
 gst_omx_component_new (GstObject * parent, const gchar * core_name,
@@ -792,6 +796,10 @@ gst_omx_component_new (GstObject * parent, const gchar * core_name,
   comp = g_slice_new0 (GstOMXComponent);
   comp->core = core;
 
+  gst_mini_object_init (GST_MINI_OBJECT_CAST (comp), 0,
+      gst_omx_component_get_type (), NULL, NULL,
+      (GstMiniObjectFreeFunction) gst_omx_component_free);
+
   if ((dot = g_strrstr (component_name, ".")))
     comp->name = g_strdup (dot + 1);
   else
@@ -859,7 +867,7 @@ gst_omx_component_new (GstObject * parent, const gchar * core_name,
 }
 
 /* NOTE: Uses comp->messages_lock */
-void
+static void
 gst_omx_component_free (GstOMXComponent * comp)
 {
   gint i, n;
@@ -900,6 +908,23 @@ gst_omx_component_free (GstOMXComponent * comp)
   g_slice_free (GstOMXComponent, comp);
 }
 
+GstOMXComponent *
+gst_omx_component_ref (GstOMXComponent * comp)
+{
+  g_return_val_if_fail (comp, NULL);
+
+  gst_mini_object_ref (GST_MINI_OBJECT_CAST (comp));
+  return comp;
+}
+
+void
+gst_omx_component_unref (GstOMXComponent * comp)
+{
+  g_return_if_fail (comp);
+
+  gst_mini_object_unref (GST_MINI_OBJECT_CAST (comp));
+}
+
 /* NOTE: Uses comp->lock and comp->messages_lock */
 OMX_ERRORTYPE
 gst_omx_component_set_state (GstOMXComponent * comp, OMX_STATETYPE state)
index 81b49dd..cab62bd 100644 (file)
@@ -327,6 +327,8 @@ struct _GstOMXPort {
 };
 
 struct _GstOMXComponent {
+  GstMiniObject mini_object;
+
   GstObject *parent;
 
   gchar *name; /* for debugging mostly */
@@ -411,9 +413,11 @@ guint64           gst_omx_parse_hacks (gchar ** hacks);
 GstOMXCore *      gst_omx_core_acquire (const gchar * filename);
 void              gst_omx_core_release (GstOMXCore * core);
 
+GType             gst_omx_component_get_type (void);
 
 GstOMXComponent * gst_omx_component_new (GstObject * parent, const gchar *core_name, const gchar *component_name, const gchar * component_role, guint64 hacks);
-void              gst_omx_component_free (GstOMXComponent * comp);
+GstOMXComponent * gst_omx_component_ref   (GstOMXComponent * comp);
+void              gst_omx_component_unref (GstOMXComponent * comp);
 
 OMX_ERRORTYPE     gst_omx_component_set_state (GstOMXComponent * comp, OMX_STATETYPE state);
 OMX_STATETYPE     gst_omx_component_get_state (GstOMXComponent * comp, GstClockTime timeout);
index d482391..1fb0bd5 100644 (file)
@@ -206,7 +206,7 @@ gst_omx_audio_dec_close (GstAudioDecoder * decoder)
   self->dec_in_port = NULL;
   self->dec_out_port = NULL;
   if (self->dec)
-    gst_omx_component_free (self->dec);
+    gst_omx_component_unref (self->dec);
   self->dec = NULL;
 
   self->started = FALSE;
index f9c2581..036b911 100644 (file)
@@ -194,7 +194,7 @@ gst_omx_audio_enc_close (GstAudioEncoder * encoder)
   self->enc_in_port = NULL;
   self->enc_out_port = NULL;
   if (self->enc)
-    gst_omx_component_free (self->enc);
+    gst_omx_component_unref (self->enc);
   self->enc = NULL;
 
   return TRUE;
index 1739739..0f1c23e 100644 (file)
@@ -358,7 +358,7 @@ gst_omx_audio_sink_close (GstAudioSink * audiosink)
   self->in_port = NULL;
   self->out_port = NULL;
   if (self->comp)
-    gst_omx_component_free (self->comp);
+    gst_omx_component_unref (self->comp);
   self->comp = NULL;
 
   GST_DEBUG_OBJECT (self, "Closed audio sink");
index c699067..6791fb7 100644 (file)
@@ -428,14 +428,14 @@ gst_omx_video_dec_close (GstVideoDecoder * decoder)
   self->dec_in_port = NULL;
   self->dec_out_port = NULL;
   if (self->dec)
-    gst_omx_component_free (self->dec);
+    gst_omx_component_unref (self->dec);
   self->dec = NULL;
 
 #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
   self->egl_in_port = NULL;
   self->egl_out_port = NULL;
   if (self->egl_render)
-    gst_omx_component_free (self->egl_render);
+    gst_omx_component_unref (self->egl_render);
   self->egl_render = NULL;
 #endif
 
index 2e9498f..a8a0212 100644 (file)
@@ -959,7 +959,7 @@ gst_omx_video_enc_close (GstVideoEncoder * encoder)
   self->enc_in_port = NULL;
   self->enc_out_port = NULL;
   if (self->enc)
-    gst_omx_component_free (self->enc);
+    gst_omx_component_unref (self->enc);
   self->enc = NULL;
 
   self->started = FALSE;