appsink: unref gstbuffer in prev sample early
authorKevin Song <kesong@nvidia.com>
Fri, 9 Jun 2023 13:08:36 +0000 (21:08 +0800)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 9 Jun 2023 14:58:49 +0000 (15:58 +0100)
commite8f9bd16490d34c9c8f729c45780f9b7bcdcce56
tree74988abe267c850de74f76adc323d292f375200d
parentcdc502f52499d6b1b8ad4a00b9de1754f8dc33de
appsink: unref gstbuffer in prev sample early

Appsink will unref prev sample in dispose function. Which is later
when V4L2 video decoder link with appsink as V4L2 video decoder
will close V4L2 device fd during GST_STATE_CHANGE_READY_TO_NULL.
If the video buffer return to V4L2 video decoder after the decoder
closed V4L2 device fd, V4L2 can't release the video frame buffer
which allocated with MMAP mode as application can't call
VIDIOC_REQBUFS 0 to release the video frame buffer by V4L2 driver.
The memory of the video frame will leak.
Unref the gstbuffer in stop() function, so V4L2 video decoder
can received all video frame buffers and release it before close
V4L2 device fd.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4820>
subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c