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 ( import (
"unsafe" "unsafe"
"github.com/tinyzimmer/go-glib/glib"
"github.com/go-gst/go-gst/gst" "github.com/go-gst/go-gst/gst"
) )
type AudioMeta struct { // AudioMeta is a Go representation of a GstAudioMeta.
ptr *C.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 { func BufferAddAudioMeta(buffer *gst.Buffer, info *Info, samples int, offsets []int) *AudioMeta {
meta := &AudioMeta{ptr} // offsets is not yet implemented, always pass `nil` or this will panic
return meta 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... // 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 // so that's what we currently assume until we inplement offsets
// properly
return wrapMetaFull(C.gst_buffer_add_audio_meta( return FromGstAudioMetaUnsafeNone(unsafe.Pointer(C.gst_buffer_add_audio_meta(
(*C.GstBuffer)(unsafe.Pointer(buffer.Instance())), (*C.GstBuffer)(unsafe.Pointer(buffer.Instance())),
info.ptr, info.ptr,
C.gsize(samples), C.gsize(samples),
/*&gSizeOffsets,*/ offsets,
nil, ))))
))
} }