switch to github.com/go-gst/go-pointer

This commit is contained in:
RSWilli
2024-11-27 17:54:38 +01:00
parent 84517be28f
commit 0577406af2
23 changed files with 58 additions and 39 deletions

View File

@@ -16,6 +16,12 @@ import (
"github.com/go-gst/go-gst/gst"
)
// #include <stdio.h>
// #include <stdlib.h>
//
// 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")

11
go.mod
View File

@@ -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

8
go.sum
View File

@@ -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=

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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.

View File

@@ -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"
)

View File

@@ -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"
)

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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

View File

@@ -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

View File

@@ -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 {

View File

@@ -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

View File

@@ -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

View File

@@ -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.