mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
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.
This commit is contained in:
parent
5d0878b48a
commit
072f49cdcf
1 changed files with 15 additions and 7 deletions
|
@ -591,7 +591,6 @@ static gboolean
|
||||||
gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
|
gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
|
||||||
{
|
{
|
||||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
g_return_val_if_fail (state->caps != NULL, FALSE);
|
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 = gst_video_codec_state_ref (state);
|
||||||
encode->input_state_changed = TRUE;
|
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 */
|
/* Store some tags */
|
||||||
{
|
{
|
||||||
GstTagList *tags = gst_tag_list_new_empty ();
|
GstTagList *tags = gst_tag_list_new_empty ();
|
||||||
|
@ -650,16 +643,24 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
|
||||||
GstVideoCodecFrame * frame)
|
GstVideoCodecFrame * frame)
|
||||||
{
|
{
|
||||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||||
|
GstPad *const srcpad = GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode);
|
||||||
GstVaapiEncoderStatus status;
|
GstVaapiEncoderStatus status;
|
||||||
GstVaapiVideoMeta *meta;
|
GstVaapiVideoMeta *meta;
|
||||||
GstVaapiSurfaceProxy *proxy;
|
GstVaapiSurfaceProxy *proxy;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
GstTaskState task_state;
|
||||||
#if USE_H264_FEI_ENCODER
|
#if USE_H264_FEI_ENCODER
|
||||||
GstVaapiFeiVideoMeta *feimeta = NULL;
|
GstVaapiFeiVideoMeta *feimeta = NULL;
|
||||||
GstVaapiEncodeClass *const klass = GST_VAAPIENCODE_GET_CLASS (venc);
|
GstVaapiEncodeClass *const klass = GST_VAAPIENCODE_GET_CLASS (venc);
|
||||||
#endif
|
#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;
|
buf = NULL;
|
||||||
ret = gst_vaapi_plugin_base_get_input_buffer (GST_VAAPI_PLUGIN_BASE (encode),
|
ret = gst_vaapi_plugin_base_get_input_buffer (GST_VAAPI_PLUGIN_BASE (encode),
|
||||||
frame->input_buffer, &buf);
|
frame->input_buffer, &buf);
|
||||||
|
@ -697,6 +698,13 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* 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:
|
error_buffer_invalid:
|
||||||
{
|
{
|
||||||
if (buf)
|
if (buf)
|
||||||
|
|
Loading…
Reference in a new issue