mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-17 05:20:46 +08:00
make audio meta use glib's transfer none
This commit is contained in:
@@ -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,
|
||||
))))
|
||||
}
|
||||
|
Reference in New Issue
Block a user