From 0577406af22d79b8e2d05f4dccd42854368ea23f Mon Sep 17 00:00:00 2001 From: RSWilli Date: Wed, 27 Nov 2024 17:54:38 +0100 Subject: [PATCH] switch to github.com/go-gst/go-pointer --- examples/plugins/registered_elements/main.go | 26 +++++++++++++++----- go.mod | 11 ++++----- go.sum | 8 +++--- gst/app/cgo_exports.go | 2 +- gst/app/gst_app_sink.go | 2 +- gst/app/gst_app_src.go | 2 +- gst/base/gst_collect_pads.go | 2 +- gst/base/gst_collect_pads_exports.go | 2 +- gst/cgo_exports.go | 2 +- gst/gst_buffer.go | 2 +- gst/gst_buffer_list.go | 2 +- gst/gst_bus.go | 2 +- gst/gst_caps.go | 2 +- gst/gst_clock.go | 2 +- gst/gst_element.go | 2 +- gst/gst_pad.go | 11 +++++++-- gst/gst_pad_exports.go | 2 +- gst/gst_plugin.go | 2 +- gst/gst_promise.go | 2 +- gst/gst_structure.go | 5 ++-- gst/gst_tag_list.go | 2 +- gst/video/cgo_exports.go | 2 +- gst/video/convert_frame.go | 2 +- 23 files changed, 58 insertions(+), 39 deletions(-) diff --git a/examples/plugins/registered_elements/main.go b/examples/plugins/registered_elements/main.go index 13105a4..3cc80bd 100644 --- a/examples/plugins/registered_elements/main.go +++ b/examples/plugins/registered_elements/main.go @@ -16,6 +16,12 @@ import ( "github.com/go-gst/go-gst/gst" ) +// #include +// #include +// +// void __lsan_do_leak_check(void); +import "C" + func run(ctx context.Context) error { ctx, cancel := signal.NotifyContext(ctx, os.Interrupt) defer cancel() @@ -83,14 +89,10 @@ func run(ctx context.Context) error { go mainloop.Run() - go func() { - <-ctx.Done() - - mainloop.Quit() - }() - <-ctx.Done() + mainloop.Quit() + pipeline.BlockSetState(gst.StateNull) gst.Deinit() @@ -110,6 +112,18 @@ func main() { runtime.GC() runtime.GC() runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + runtime.GC() + + C.__lsan_do_leak_check() prof := pprof.Lookup("go-glib-reffed-objects") diff --git a/go.mod b/go.mod index 66addc8..698d259 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,10 @@ module github.com/go-gst/go-gst -go 1.23.1 +go 1.23.2 -toolchain go1.23.2 - -require github.com/mattn/go-pointer v0.0.1 - -require github.com/go-gst/go-glib v1.4.1-0.20241125224403-1748a2b7e9e1 +require ( + github.com/go-gst/go-glib v1.4.1-0.20241127164645-1aa7cfba8dcf + github.com/go-gst/go-pointer v0.0.0-20241127163939-ba766f075b4c +) require golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect diff --git a/go.sum b/go.sum index 1b4c833..638ad2f 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ -github.com/go-gst/go-glib v1.4.1-0.20241125224403-1748a2b7e9e1 h1:0foANpP83iNay7XN5lp3Ug3ywP7zQterXoOOtEH0CHA= -github.com/go-gst/go-glib v1.4.1-0.20241125224403-1748a2b7e9e1/go.mod h1:GUIpWmkxQ1/eL+FYSjKpLDyTZx6Vgd9nNXt8dA31d5M= -github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= -github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= +github.com/go-gst/go-glib v1.4.1-0.20241127164645-1aa7cfba8dcf h1:mffP/eHbVYx9C1dAV7ouqdE48B5EbARTPVAzkqIu09Q= +github.com/go-gst/go-glib v1.4.1-0.20241127164645-1aa7cfba8dcf/go.mod h1:ZWT4LXOO2PH8lSNu/dR5O2yoNQJKEgmijNa2d7nByK8= +github.com/go-gst/go-pointer v0.0.0-20241127163939-ba766f075b4c h1:x8kKRVDmz5BRlolmDZGcsuZ1l+js6TRL3QWBJjGVctM= +github.com/go-gst/go-pointer v0.0.0-20241127163939-ba766f075b4c/go.mod h1:qKw5ZZ0U58W6PU/7F/Lopv+14nKYmdXlOd7VnAZ17Mk= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= diff --git a/gst/app/cgo_exports.go b/gst/app/cgo_exports.go index 1c0c3b8..8373084 100644 --- a/gst/app/cgo_exports.go +++ b/gst/app/cgo_exports.go @@ -7,7 +7,7 @@ import ( "github.com/go-gst/go-glib/glib" "github.com/go-gst/go-gst/gst" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) func getSinkCbsFromPtr(userData C.gpointer) *SinkCallbacks { diff --git a/gst/app/gst_app_sink.go b/gst/app/gst_app_sink.go index bb15b83..24b64ba 100644 --- a/gst/app/gst_app_sink.go +++ b/gst/app/gst_app_sink.go @@ -21,7 +21,7 @@ import ( "errors" "unsafe" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" "github.com/go-gst/go-gst/gst" "github.com/go-gst/go-gst/gst/base" diff --git a/gst/app/gst_app_src.go b/gst/app/gst_app_src.go index 888870d..092323c 100644 --- a/gst/app/gst_app_src.go +++ b/gst/app/gst_app_src.go @@ -22,7 +22,7 @@ import ( "github.com/go-gst/go-gst/gst" "github.com/go-gst/go-gst/gst/base" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // SourceCallbacks represents callbacks to configure on an AppSource. diff --git a/gst/base/gst_collect_pads.go b/gst/base/gst_collect_pads.go index 4e6249e..8d6cc88 100644 --- a/gst/base/gst_collect_pads.go +++ b/gst/base/gst_collect_pads.go @@ -60,7 +60,7 @@ import ( "time" "unsafe" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" "github.com/go-gst/go-gst/gst" ) diff --git a/gst/base/gst_collect_pads_exports.go b/gst/base/gst_collect_pads_exports.go index eb28af5..a986aad 100644 --- a/gst/base/gst_collect_pads_exports.go +++ b/gst/base/gst_collect_pads_exports.go @@ -8,7 +8,7 @@ import ( "time" "unsafe" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" "github.com/go-gst/go-gst/gst" ) diff --git a/gst/cgo_exports.go b/gst/cgo_exports.go index 9207fc1..4d9515d 100644 --- a/gst/cgo_exports.go +++ b/gst/cgo_exports.go @@ -13,7 +13,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) //export goElementCallAsync diff --git a/gst/gst_buffer.go b/gst/gst_buffer.go index dfea015..ee7906b 100644 --- a/gst/gst_buffer.go +++ b/gst/gst_buffer.go @@ -26,7 +26,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // GetMaxBufferMemory returns the maximum amount of memory a buffer can hold. diff --git a/gst/gst_buffer_list.go b/gst/gst_buffer_list.go index 345975f..5e7a114 100644 --- a/gst/gst_buffer_list.go +++ b/gst/gst_buffer_list.go @@ -15,7 +15,7 @@ import ( "runtime" "unsafe" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // BufferList is a go wrapper around a GstBufferList for grouping Buffers diff --git a/gst/gst_bus.go b/gst/gst_bus.go index da6f49d..d16a686 100644 --- a/gst/gst_bus.go +++ b/gst/gst_bus.go @@ -30,7 +30,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // Bus is a Go wrapper around a GstBus. It provides convenience methods for diff --git a/gst/gst_caps.go b/gst/gst_caps.go index 86ed44e..a185357 100644 --- a/gst/gst_caps.go +++ b/gst/gst_caps.go @@ -18,7 +18,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // TypeCaps is the static Glib Type for a GstCaps. diff --git a/gst/gst_clock.go b/gst/gst_clock.go index 7992290..ac75cf5 100644 --- a/gst/gst_clock.go +++ b/gst/gst_clock.go @@ -26,7 +26,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) type ClockTime C.GstClockTime diff --git a/gst/gst_element.go b/gst/gst_element.go index bdf116b..30a5ef1 100644 --- a/gst/gst_element.go +++ b/gst/gst_element.go @@ -47,7 +47,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // Element is a Go wrapper around a GstElement. diff --git a/gst/gst_pad.go b/gst/gst_pad.go index 64a6ea8..98fcf1e 100644 --- a/gst/gst_pad.go +++ b/gst/gst_pad.go @@ -81,10 +81,11 @@ import "C" import ( "errors" + "runtime" "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // PadFuncMap is an type of map for registering callbacks to a pad instance. @@ -1138,7 +1139,13 @@ func (p *PadProbeInfo) GetEvent() *Event { if ev == nil { return nil } - return wrapEvent(ev) + + event := wrapEvent(ev) + + event.Ref() + runtime.SetFinalizer(event, (*Event).Unref) + + return event } // GetQuery returns the query, if any, inside this probe info. diff --git a/gst/gst_pad_exports.go b/gst/gst_pad_exports.go index f60b935..0a123ea 100644 --- a/gst/gst_pad_exports.go +++ b/gst/gst_pad_exports.go @@ -8,7 +8,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) func getParent(parent *C.GstObject) *Object { diff --git a/gst/gst_plugin.go b/gst/gst_plugin.go index 8e982ae..6328926 100644 --- a/gst/gst_plugin.go +++ b/gst/gst_plugin.go @@ -54,7 +54,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // PluginMetadata represents the information to include when registering a new plugin diff --git a/gst/gst_promise.go b/gst/gst_promise.go index 7856c76..05129a1 100644 --- a/gst/gst_promise.go +++ b/gst/gst_promise.go @@ -20,7 +20,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) type PromiseResult int diff --git a/gst/gst_structure.go b/gst/gst_structure.go index 3c6f605..78f2c8a 100644 --- a/gst/gst_structure.go +++ b/gst/gst_structure.go @@ -22,7 +22,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // Structure is a go implementation of a C GstStructure. @@ -212,8 +212,7 @@ func (s *Structure) ToGValue() (*glib.Value, error) { // marshalStructure is used to extract the GstStructure from a GValue. func marshalStructure(p unsafe.Pointer) (interface{}, error) { c := C.gst_value_get_structure(toGValue(p)) - obj := (*C.GstStructure)(unsafe.Pointer(c)) - return structureFromGlibNone(obj), nil + return structureFromGlibNone(c), nil } func wrapStructure(st *C.GstStructure) *Structure { diff --git a/gst/gst_tag_list.go b/gst/gst_tag_list.go index f7c3220..a30389a 100644 --- a/gst/gst_tag_list.go +++ b/gst/gst_tag_list.go @@ -19,7 +19,7 @@ import ( "unsafe" "github.com/go-gst/go-glib/glib" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // TagList is a go wrapper around a GstTagList. For now, until the rest of the methods are diff --git a/gst/video/cgo_exports.go b/gst/video/cgo_exports.go index dada5de..8c7bfb5 100644 --- a/gst/video/cgo_exports.go +++ b/gst/video/cgo_exports.go @@ -9,7 +9,7 @@ import ( "unsafe" "github.com/go-gst/go-gst/gst" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) //export goVideoGDestroyNotifyFunc diff --git a/gst/video/convert_frame.go b/gst/video/convert_frame.go index 790ee7c..25ba36b 100644 --- a/gst/video/convert_frame.go +++ b/gst/video/convert_frame.go @@ -22,7 +22,7 @@ import ( "unsafe" "github.com/go-gst/go-gst/gst" - gopointer "github.com/mattn/go-pointer" + gopointer "github.com/go-gst/go-pointer" ) // ConvertSampleCallback represents a callback from a video convert opereration.