major rework of reference handling

This commit is contained in:
Avi Zimmerman
2021-01-19 00:18:30 +02:00
parent 63a53be42a
commit 1f7d60b390
79 changed files with 1239 additions and 800 deletions

View File

@@ -86,7 +86,7 @@ func NewBin(name string) *Bin {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
bin := C.gst_bin_new((*C.gchar)(unsafe.Pointer(cName)))
return wrapBin(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(bin))})
return wrapBin(glib.TransferNone(unsafe.Pointer(bin)))
}
// ToGstBin wraps the given glib.Object, gst.Object, or gst.Element in a Bin instance. Only
@@ -114,7 +114,7 @@ func (b *Bin) GetElementByName(name string) (*Element, error) {
if elem == nil {
return nil, fmt.Errorf("Could not find element with name %s", name)
}
return wrapElement(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(elem))}), nil
return wrapElement(glib.TransferFull(unsafe.Pointer(elem))), nil
}
// GetElementByNameRecursive returns the element with the given name. If it is not
@@ -126,7 +126,7 @@ func (b *Bin) GetElementByNameRecursive(name string) (*Element, error) {
if elem == nil {
return nil, fmt.Errorf("Could not find element with name %s", name)
}
return wrapElement(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(elem))}), nil
return wrapElement(glib.TransferFull(unsafe.Pointer(elem))), nil
}
// GetElements returns a list of the elements added to this pipeline.
@@ -171,7 +171,7 @@ func (b *Bin) GetByInterface(iface glib.Interface) (*Element, error) {
if elem == nil {
return nil, fmt.Errorf("Could not find any elements implementing %s", iface.Type().Name())
}
return wrapElement(toGObject(unsafe.Pointer(elem))), nil
return wrapElement(glib.TransferFull(unsafe.Pointer(elem))), nil
}
// GetAllByInterface looks for all elements inside the bin that implements the given interface. You can
@@ -235,7 +235,7 @@ func (b *Bin) FindUnlinkedPad(direction PadDirection) *Pad {
if pad == nil {
return nil
}
return wrapPad(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(pad))})
return wrapPad(glib.TransferFull(unsafe.Pointer(pad)))
}
// GetSuppressedFlags returns the suppressed flags of the bin.
@@ -321,7 +321,7 @@ func iteratorToElementSlice(iterator *C.GstIterator) ([]*Element, error) {
case C.GST_ITERATOR_OK:
cElemVoid := C.g_value_get_object((*C.GValue)(gval))
cElem := (*C.GstElement)(cElemVoid)
elems = append(elems, wrapElement(&glib.Object{GObject: glib.ToGObject(unsafe.Pointer(cElem))}))
elems = append(elems, wrapElement(glib.TransferFull(unsafe.Pointer(cElem))))
C.g_value_reset((*C.GValue)(gval))
default:
return nil, errors.New("Element iterator failed")