mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-13 09:45:27 +00:00
x264enc: Use video encoder stream lock to avoid deadlock
This commit is contained in:
parent
43093dffea
commit
017bb86d82
1 changed files with 11 additions and 10 deletions
|
@ -985,7 +985,7 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
/* make sure that the encoder is closed */
|
/* make sure that the encoder is closed */
|
||||||
gst_x264_enc_close_encoder (encoder);
|
gst_x264_enc_close_encoder (encoder);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||||
|
|
||||||
gst_x264_enc_build_tunings_string (encoder);
|
gst_x264_enc_build_tunings_string (encoder);
|
||||||
|
|
||||||
|
@ -1172,7 +1172,7 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
|
|
||||||
encoder->reconfig = FALSE;
|
encoder->reconfig = FALSE;
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
|
|
||||||
encoder->x264enc = x264_encoder_open (&encoder->x264param);
|
encoder->x264enc = x264_encoder_open (&encoder->x264param);
|
||||||
if (!encoder->x264enc) {
|
if (!encoder->x264enc) {
|
||||||
|
@ -1184,7 +1184,7 @@ gst_x264_enc_init_encoder (GstX264Enc * encoder)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
unlock_and_return:
|
unlock_and_return:
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1668,11 +1668,12 @@ gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_OBJECT_LOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||||
if (encoder->reconfig) {
|
if (encoder->reconfig) {
|
||||||
encoder->reconfig = FALSE;
|
encoder->reconfig = FALSE;
|
||||||
if (x264_encoder_reconfig (encoder->x264enc, &encoder->x264param) < 0)
|
if (x264_encoder_reconfig (encoder->x264enc, &encoder->x264param) < 0)
|
||||||
GST_WARNING_OBJECT (encoder, "Could not reconfigure");
|
GST_WARNING_OBJECT (encoder, "Could not reconfigure");
|
||||||
|
|
||||||
gst_x264_enc_set_latency (encoder);
|
gst_x264_enc_set_latency (encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1685,7 +1686,7 @@ gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
|
||||||
pic_in->i_type = X264_TYPE_IDR;
|
pic_in->i_type = X264_TYPE_IDR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
|
|
||||||
encoder_return = x264_encoder_encode (encoder->x264enc,
|
encoder_return = x264_encoder_encode (encoder->x264enc,
|
||||||
&nal, i_nal, pic_in, &pic_out);
|
&nal, i_nal, pic_in, &pic_out);
|
||||||
|
@ -1799,7 +1800,7 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
encoder = GST_X264_ENC (object);
|
encoder = GST_X264_ENC (object);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||||
/* state at least matters for sps, bytestream, pass,
|
/* state at least matters for sps, bytestream, pass,
|
||||||
* and so by extension ... */
|
* and so by extension ... */
|
||||||
|
|
||||||
|
@ -1994,14 +1995,14 @@ gst_x264_enc_set_property (GObject * object, guint prop_id,
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
wrong_state:
|
wrong_state:
|
||||||
{
|
{
|
||||||
GST_WARNING_OBJECT (encoder, "setting property in wrong state");
|
GST_WARNING_OBJECT (encoder, "setting property in wrong state");
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2013,7 +2014,7 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
encoder = GST_X264_ENC (object);
|
encoder = GST_X264_ENC (object);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_THREADS:
|
case ARG_THREADS:
|
||||||
g_value_set_uint (value, encoder->threads);
|
g_value_set_uint (value, encoder->threads);
|
||||||
|
@ -2134,7 +2135,7 @@ gst_x264_enc_get_property (GObject * object, guint prop_id,
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue