v4l2videoenc: unref buffer pool after usage properly
Current code in gst-plugins-good/sys/v4l2/gstv4l2videoenc.c has refcount issue of OUTPUT bufferpool. opool has chance to not unref after opool has been activated.
{
/* Ensure input internal output pool is active */
GstBufferPool *opool = gst_v4l2_object_get_buffer_pool (self->v4l2output);
if (!gst_buffer_pool_is_active (opool)) {
GstStructure *config = gst_buffer_pool_get_config (opool);
guint min = MAX (self->v4l2output->min_buffers,
GST_V4L2_MIN_BUFFERS (self->v4l2output));
gst_buffer_pool_config_set_params (config, self->input_state->caps,
self->v4l2output->info.size, min, min);
/* There is no reason to refuse this config */
if (!gst_buffer_pool_set_config (opool, config)) {
config = gst_buffer_pool_get_config (opool);
if (gst_buffer_pool_config_validate_params (config,
self->input_state->caps, self->v4l2output->info.size, min,
min)) {
gst_structure_free (config);
if (opool)
gst_object_unref (opool);
goto activate_failed;
}
if (!gst_buffer_pool_set_config (opool, config)) {
if (opool)
gst_object_unref (opool);
goto activate_failed;
}
}
if (!gst_buffer_pool_set_active (opool, TRUE)) {
if (opool)
gst_object_unref (opool);
goto activate_failed;
}
if (opool)
gst_object_unref (opool);
}
}
Edited by Qi Hou