make audio meta use glib's transfer none

This commit is contained in:
Dan Jenkins
2023-08-25 10:27:02 +01:00
parent 0948e6783b
commit 7c7d4d53e9

View File

@@ -8,29 +8,32 @@ import "C"
import (
"unsafe"
"github.com/tinyzimmer/go-glib/glib"
"github.com/go-gst/go-gst/gst"
)
type AudioMeta struct {
ptr *C.GstAudioMeta
// AudioMeta is a Go representation of a GstAudioMeta.
type AudioMeta struct{ *Object }
// FromGstAudioMetaUnsafeNone wraps the given audioMeta with a ref and finalizer.
func FromGstAudioMetaUnsafeNone(audioMeta unsafe.Pointer) *AudioMeta {
return &AudioMeta{wrapObject(glib.TransferNone(audioMeta))}
}
func wrapMetaFull(ptr *C.GstAudioMeta) *AudioMeta {
meta := &AudioMeta{ptr}
return meta
func BufferAddAudioMeta(buffer *gst.Buffer, info *Info, samples int, offsets []int) *AudioMeta {
// offsets is not yet implemented, always pass `nil` or this will panic
if offsets != nil {
panic("offsets is not implemented")
}
func BufferAddAudioMeta(buffer *gst.Buffer, info *Info, samples int /*, offsets *[]int*/) *AudioMeta {
/*gSizeOffsets := C.gsize(unsafe.Sizeof(unsafe.Pointer(offsets)))*/
// gSizeOffsets := C.gsize(unsafe.Sizeof(unsafe.Pointer(offsets)))
// if you pass in NULL as the last param then gstreamer assumes things are tightly packed...
// and they are for me so this makes things work... but obviously would be nice for it to work
// properly
// so that's what we currently assume until we inplement offsets
return wrapMetaFull(C.gst_buffer_add_audio_meta(
return FromGstAudioMetaUnsafeNone(unsafe.Pointer(C.gst_buffer_add_audio_meta(
(*C.GstBuffer)(unsafe.Pointer(buffer.Instance())),
info.ptr,
C.gsize(samples),
/*&gSizeOffsets,*/
nil,
))
offsets,
))))
}