summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2018-11-12 13:39:51 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2018-11-14 12:55:49 +0100
commit072f49cdcff4d68b9275fd36e7796cd6f5c4606f (patch)
tree18e768e851af341d52041ff3be51d3166a6b3447
parent5d0878b48abddff4f646c7fa774dec2b199fdd92 (diff)
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.
-rw-r--r--gst/vaapi/gstvaapiencode.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c
index 97cfd0dc..489df0bc 100644
--- a/gst/vaapi/gstvaapiencode.c
+++ b/gst/vaapi/gstvaapiencode.c
@@ -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)