Now removing from classers after the free method

This commit is contained in:
Quentin Renard
2024-10-04 10:45:40 +02:00
parent ff9ebd25ed
commit 680b5f933c
9 changed files with 92 additions and 18 deletions

View File

@@ -38,8 +38,15 @@ func (cc *CodecContext) Free() {
C.av_buffer_unref(&cc.hdc.c)
cc.hdc = nil
}
classers.del(cc)
C.avcodec_free_context(&cc.c)
if cc.c != nil {
// Make sure to clone the classer before freeing the object since
// the C free method resets the pointer
c := newClonedClasser(cc)
C.avcodec_free_context(&cc.c)
// Make sure to remove from classers after freeing the object since
// the C free method may use methods needing the classer
classers.del(c)
}
}
func (cc *CodecContext) String() string {