mirror of
https://github.com/asticode/go-astiav.git
synced 2025-11-01 20:12:51 +08:00
Fixed hardware device context buffer unref
This commit is contained in:
@@ -53,6 +53,9 @@ func newCodecContextFromC(c *C.struct_AVCodecContext) *CodecContext {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) Free() {
|
||||
if cc.c.hw_device_ctx != nil {
|
||||
C.av_buffer_unref(&cc.c.hw_device_ctx)
|
||||
}
|
||||
C.avcodec_free_context(&cc.c)
|
||||
}
|
||||
|
||||
@@ -290,6 +293,9 @@ func (cc *CodecContext) SendFrame(f *Frame) error {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) SetHardwareDeviceContext(hdc *HardwareDeviceContext) {
|
||||
if cc.c.hw_device_ctx != nil {
|
||||
C.av_buffer_unref(&cc.c.hw_device_ctx)
|
||||
}
|
||||
cc.c.hw_device_ctx = C.av_buffer_ref(hdc.c)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,3 @@ func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *D
|
||||
}
|
||||
return &hdc, nil
|
||||
}
|
||||
|
||||
func (hdc *HardwareDeviceContext) Free() {
|
||||
if hdc.c != nil {
|
||||
C.av_buffer_unref(&hdc.c)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user