mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:46:13 +00:00
msdk: dec: fix leaks when flushing
https://bugzilla.gnome.org/show_bug.cgi?id=793708
This commit is contained in:
parent
c9faf0d612
commit
8a3630ffd7
1 changed files with 16 additions and 8 deletions
|
@ -75,6 +75,8 @@ typedef struct _MsdkSurface
|
||||||
GstVideoFrame copy;
|
GstVideoFrame copy;
|
||||||
} MsdkSurface;
|
} MsdkSurface;
|
||||||
|
|
||||||
|
static gboolean gst_msdkdec_flush (GstVideoDecoder * decoder);
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
allocate_output_buffer (GstMsdkDec * thiz, GstBuffer ** buffer)
|
allocate_output_buffer (GstMsdkDec * thiz, GstBuffer ** buffer)
|
||||||
{
|
{
|
||||||
|
@ -513,6 +515,9 @@ static gboolean
|
||||||
gst_msdkdec_stop (GstVideoDecoder * decoder)
|
gst_msdkdec_stop (GstVideoDecoder * decoder)
|
||||||
{
|
{
|
||||||
GstMsdkDec *thiz = GST_MSDKDEC (decoder);
|
GstMsdkDec *thiz = GST_MSDKDEC (decoder);
|
||||||
|
|
||||||
|
gst_msdkdec_flush (decoder);
|
||||||
|
|
||||||
if (thiz->input_state) {
|
if (thiz->input_state) {
|
||||||
gst_video_codec_state_unref (thiz->input_state);
|
gst_video_codec_state_unref (thiz->input_state);
|
||||||
thiz->input_state = NULL;
|
thiz->input_state = NULL;
|
||||||
|
@ -603,11 +608,11 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
|
||||||
task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task);
|
task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task);
|
||||||
flow = gst_msdkdec_finish_task (thiz, task);
|
flow = gst_msdkdec_finish_task (thiz, task);
|
||||||
if (flow != GST_FLOW_OK)
|
if (flow != GST_FLOW_OK)
|
||||||
goto exit;
|
goto error;
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
flow = allocate_output_buffer (thiz, &buffer);
|
flow = allocate_output_buffer (thiz, &buffer);
|
||||||
if (flow != GST_FLOW_OK)
|
if (flow != GST_FLOW_OK)
|
||||||
goto exit;
|
goto error;
|
||||||
surface = get_surface (thiz, buffer);
|
surface = get_surface (thiz, buffer);
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
/* Can't get a surface for some reason, finish tasks to see if
|
/* Can't get a surface for some reason, finish tasks to see if
|
||||||
|
@ -617,7 +622,7 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
|
||||||
task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task);
|
task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task);
|
||||||
flow = gst_msdkdec_finish_task (thiz, task);
|
flow = gst_msdkdec_finish_task (thiz, task);
|
||||||
if (flow != GST_FLOW_OK)
|
if (flow != GST_FLOW_OK)
|
||||||
goto exit;
|
goto error;
|
||||||
surface = get_surface (thiz, buffer);
|
surface = get_surface (thiz, buffer);
|
||||||
if (surface)
|
if (surface)
|
||||||
break;
|
break;
|
||||||
|
@ -625,7 +630,7 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
GST_ERROR_OBJECT (thiz, "Couldn't get a surface");
|
GST_ERROR_OBJECT (thiz, "Couldn't get a surface");
|
||||||
flow = GST_FLOW_ERROR;
|
flow = GST_FLOW_ERROR;
|
||||||
goto exit;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,12 +678,17 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
|
||||||
flow = GST_FLOW_OK;
|
flow = GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
|
||||||
if (surface)
|
if (surface)
|
||||||
free_surface (thiz, surface);
|
free_surface (thiz, surface);
|
||||||
|
|
||||||
gst_buffer_unmap (frame->input_buffer, &map_info);
|
gst_buffer_unmap (frame->input_buffer, &map_info);
|
||||||
return flow;
|
return flow;
|
||||||
|
|
||||||
|
error:
|
||||||
|
gst_buffer_unmap (frame->input_buffer, &map_info);
|
||||||
|
gst_video_decoder_drop_frame (decoder, frame);
|
||||||
|
|
||||||
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBufferPool *
|
static GstBufferPool *
|
||||||
|
@ -936,9 +946,7 @@ gst_msdkdec_drain (GstVideoDecoder * decoder)
|
||||||
|
|
||||||
for (i = 0; i < thiz->tasks->len; i++) {
|
for (i = 0; i < thiz->tasks->len; i++) {
|
||||||
task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task);
|
task = &g_array_index (thiz->tasks, MsdkDecTask, thiz->next_task);
|
||||||
flow = gst_msdkdec_finish_task (thiz, task);
|
gst_msdkdec_finish_task (thiz, task);
|
||||||
if (flow != GST_FLOW_OK)
|
|
||||||
return flow;
|
|
||||||
thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len;
|
thiz->next_task = (thiz->next_task + 1) % thiz->tasks->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue