Commit 072f49cd authored by Michael Olbrich's avatar Michael Olbrich
Browse files

vaapiencode: don't start src pad task in set_format

Otherwise the task may be restarted during shutdown. Start the task in
gst_vaapiencode_handle_frame() instead.
parent 5d0878b4
Pipeline #8572 passed with stages
in 1 minute and 37 seconds
......@@ -591,7 +591,6 @@ static gboolean
gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
{
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
gboolean ret;
g_return_val_if_fail (state->caps != NULL, FALSE);
......@@ -610,12 +609,6 @@ gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
encode->input_state = gst_video_codec_state_ref (state);
encode->input_state_changed = TRUE;
ret = gst_pad_start_task (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode),
(GstTaskFunction) gst_vaapiencode_buffer_loop, encode, NULL);
if (!ret)
return FALSE;
/* Store some tags */
{
GstTagList *tags = gst_tag_list_new_empty ();
......@@ -650,16 +643,24 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
GstVideoCodecFrame * frame)
{
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
GstPad *const srcpad = GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode);
GstVaapiEncoderStatus status;
GstVaapiVideoMeta *meta;
GstVaapiSurfaceProxy *proxy;
GstFlowReturn ret;
GstBuffer *buf;
GstTaskState task_state;
#if USE_H264_FEI_ENCODER
GstVaapiFeiVideoMeta *feimeta = NULL;
GstVaapiEncodeClass *const klass = GST_VAAPIENCODE_GET_CLASS (venc);
#endif
task_state = gst_pad_get_task_state (srcpad);
if (task_state == GST_TASK_STOPPED || task_state == GST_TASK_PAUSED)
if (!gst_pad_start_task (srcpad,
(GstTaskFunction) gst_vaapiencode_buffer_loop, encode, NULL))
goto error_task_failed;
buf = NULL;
ret = gst_vaapi_plugin_base_get_input_buffer (GST_VAAPI_PLUGIN_BASE (encode),
frame->input_buffer, &buf);
......@@ -697,6 +698,13 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
return GST_FLOW_OK;
/* ERRORS */
error_task_failed:
{
GST_ELEMENT_ERROR (venc, RESOURCE, FAILED,
("Failed to start encoding thread."), (NULL));
gst_video_codec_frame_unref (frame);
return GST_FLOW_ERROR;
}
error_buffer_invalid:
{
if (buf)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment