avaudenc: fix memory leak of refcontext after finalize.
When using the avenc_g722 encoder we seem to leek the refcontext when the element is destroyed. This is verified by the following valgrind trace:
==3527== 2,232 bytes in 1 blocks are definitely lost in loss record 4,295 of 4,341
==3527== at 0x483AEC3: memalign (vg_replace_malloc.c:898)
==3527== by 0x483AFF0: posix_memalign (vg_replace_malloc.c:1062)
==3527== by 0x90A3FB5: av_malloc (in /usr/lib/libavutil.so.56.22.100)
==3527== by 0x90A41BA: av_mallocz (in /usr/lib/libavutil.so.56.22.100)
==3527== by 0x80F3596: ??? (in /usr/lib/libavcodec.so.58.35.100)
==3527== by 0x80F3637: avcodec_alloc_context3 (in /usr/lib/libavcodec.so.58.35.100)
==3527== by 0x6FF9B7A: gst_ffmpegaudenc_init.lto_priv.0 (gstavaudenc.c:164)
==3527== by 0x4B052BF: g_type_create_instance (in /usr/lib/libgobject-2.0.so.0.6000.5)
==3527== by 0x4B2163D: ??? (in /usr/lib/libgobject-2.0.so.0.6000.5)
==3527== by 0x4B22A54: g_object_new_with_properties (in /usr/lib/libgobject-2.0.so.0.6000.5)
==3527== by 0x4B22B51: g_object_new (in /usr/lib/libgobject-2.0.so.0.6000.5)
==3527== by 0x49424CE: gst_element_factory_create (in /usr/lib/libgstreamer-1.0.so.0.1600.0)
==3527== by 0x4942EEA: gst_element_factory_make (in /usr/lib/libgstreamer-1.0.so.0.1600.0)
The refcontext needs to be closed before it is freed in finalize.
Edited by Knut Andre Tidemann