summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-02-24 23:48:19 +1100
committerMatthew Waters <matthew@centricular.com>2016-02-25 00:07:14 +1100
commitb48049a171fea505eed19fd5e7d3ce79976156c1 (patch)
tree0f2c2a8ea15f5c48ddffa516920560c534190115
parentc086540291d098245133c7781bb88a4622d241e0 (diff)
nvenc: release the frames and list when searching for an output buffer
Fixes a massive leak in: videotestsrc ! nvh264enc ! fakesink
-rw-r--r--sys/nvenc/gstnvbaseenc.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/nvenc/gstnvbaseenc.c b/sys/nvenc/gstnvbaseenc.c
index 6babb31ce..1bbdfe3b7 100644
--- a/sys/nvenc/gstnvbaseenc.c
+++ b/sys/nvenc/gstnvbaseenc.c
@@ -511,23 +511,33 @@ gst_nv_base_enc_finalize (GObject * obj)
static GstVideoCodecFrame *
_find_frame_with_output_buffer (GstNvBaseEnc * nvenc, NV_ENC_OUTPUT_PTR out_buf)
{
- GList *l = gst_video_encoder_get_frames (GST_VIDEO_ENCODER (nvenc));
+ GList *l, *walk = gst_video_encoder_get_frames (GST_VIDEO_ENCODER (nvenc));
+ GstVideoCodecFrame *ret = NULL;
gint i;
- for (; l; l = l->next) {
+ for (l = walk; l; l = l->next) {
GstVideoCodecFrame *frame = (GstVideoCodecFrame *) l->data;
struct frame_state *state = frame->user_data;
+ if (!state)
+ continue;
+
for (i = 0; i < N_BUFFERS_PER_FRAME; i++) {
+
if (!state->out_bufs[i])
break;
if (state->out_bufs[i] == out_buf)
- return frame;
+ ret = frame;
}
}
- return NULL;
+ if (ret)
+ gst_video_codec_frame_ref (ret);
+
+ g_list_free_full (walk, (GDestroyNotify) gst_video_codec_frame_unref);
+
+ return ret;
}
static gpointer