Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call to gst_ctf_close and ref counting #110

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions plugins/tracers/gstplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ plugin_init (GstPlugin * plugin)
if (!gst_tracer_register (plugin, "buffer", gst_buffer_tracer_get_type ())) {
return FALSE;
}
if (!gst_ctf_init ()) {
return FALSE;
}

return TRUE;
}
Expand Down
13 changes: 13 additions & 0 deletions plugins/tracers/gstsharktracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "gstsharktracer.h"
#include "gstctf.h"

GST_DEBUG_CATEGORY_STATIC (gst_shark_debug);
#define GST_CAT_DEFAULT gst_shark_debug
Expand All @@ -34,6 +35,8 @@ struct _GstSharkTracerPrivate
GHashTable *myhooks;
};

static volatile gint g_shark_tracer_refcount = 0;

static void gst_shark_tracer_constructed (GObject * object);
static void gst_shark_tracer_finalize (GObject * object);
static void gst_shark_tracer_save_params (GstSharkTracer * self);
Expand Down Expand Up @@ -220,9 +223,15 @@ gst_shark_tracer_fill_hooks (GstSharkTracerPrivate * priv)
static void
gst_shark_tracer_constructed (GObject * object)
{
gint prev_count;
GstSharkTracer *self = GST_SHARK_TRACER (object);

gst_shark_tracer_save_params (self);

prev_count = g_atomic_int_add (&g_shark_tracer_refcount, 1);
if (prev_count == 0) {
gst_ctf_init ();
}
}

static void
Expand All @@ -249,6 +258,10 @@ gst_shark_tracer_finalize (GObject * object)
g_hash_table_unref (priv->myhooks);

G_OBJECT_CLASS (gst_shark_tracer_parent_class)->finalize (object);

if (g_atomic_int_dec_and_test (&g_shark_tracer_refcount)) {
gst_ctf_close ();
}
}

static void
Expand Down