mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
x265enc: fix deadlock on reconfig
Don't attempt to obtain encoder lock that is already held by gst_x265_enc_encode_frame(). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1671>
This commit is contained in:
parent
d3d73f61fa
commit
6f2f15b5fb
1 changed files with 21 additions and 16 deletions
|
@ -785,15 +785,8 @@ gst_x265_enc_parse_options (GstX265Enc * encoder, const gchar * str)
|
||||||
return !ret;
|
return !ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* gst_x265_enc_init_encoder
|
|
||||||
* @encoder: Encoder which should be initialized.
|
|
||||||
*
|
|
||||||
* Initialize x265 encoder.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
gst_x265_enc_init_encoder_locked (GstX265Enc * encoder)
|
||||||
{
|
{
|
||||||
GstVideoInfo *info;
|
GstVideoInfo *info;
|
||||||
guint bitdepth;
|
guint bitdepth;
|
||||||
|
@ -809,7 +802,6 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
/* make sure that the encoder is closed */
|
/* make sure that the encoder is closed */
|
||||||
gst_x265_enc_close_encoder (encoder);
|
gst_x265_enc_close_encoder (encoder);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (encoder);
|
|
||||||
bitdepth = GST_VIDEO_INFO_COMP_DEPTH (info, 0);
|
bitdepth = GST_VIDEO_INFO_COMP_DEPTH (info, 0);
|
||||||
encoder->api = NULL;
|
encoder->api = NULL;
|
||||||
|
|
||||||
|
@ -837,7 +829,6 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
|
|
||||||
if (!encoder->api) {
|
if (!encoder->api) {
|
||||||
GST_ERROR_OBJECT (encoder, "no %d bitdepth vtable available", bitdepth);
|
GST_ERROR_OBJECT (encoder, "no %d bitdepth vtable available", bitdepth);
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,7 +836,6 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
x265_preset_names[encoder->speed_preset - 1],
|
x265_preset_names[encoder->speed_preset - 1],
|
||||||
x265_tune_names[encoder->tune - 1]) < 0) {
|
x265_tune_names[encoder->tune - 1]) < 0) {
|
||||||
GST_DEBUG_OBJECT (encoder, "preset or tune unrecognized");
|
GST_DEBUG_OBJECT (encoder, "preset or tune unrecognized");
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +919,6 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
|
|
||||||
if (i == encoder->peer_profiles->len) {
|
if (i == encoder->peer_profiles->len) {
|
||||||
GST_ERROR_OBJECT (encoder, "Couldn't apply peer profile");
|
GST_ERROR_OBJECT (encoder, "Couldn't apply peer profile");
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +969,6 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
if (gst_x265_enc_parse_options (encoder,
|
if (gst_x265_enc_parse_options (encoder,
|
||||||
encoder->option_string_prop->str) == FALSE) {
|
encoder->option_string_prop->str) == FALSE) {
|
||||||
GST_DEBUG_OBJECT (encoder, "Your option-string contains errors.");
|
GST_DEBUG_OBJECT (encoder, "Your option-string contains errors.");
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -990,8 +978,6 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
/* good start, will be corrected if needed */
|
/* good start, will be corrected if needed */
|
||||||
encoder->dts_offset = 0;
|
encoder->dts_offset = 0;
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
|
||||||
|
|
||||||
encoder->x265enc = encoder->api->encoder_open (&encoder->x265param);
|
encoder->x265enc = encoder->api->encoder_open (&encoder->x265param);
|
||||||
if (!encoder->x265enc) {
|
if (!encoder->x265enc) {
|
||||||
GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
|
GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
|
||||||
|
@ -1004,6 +990,25 @@ gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gst_x265_enc_init_encoder
|
||||||
|
* @encoder: Encoder which should be initialized.
|
||||||
|
*
|
||||||
|
* Initialize x265 encoder.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
gst_x265_enc_init_encoder (GstX265Enc * encoder)
|
||||||
|
{
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (encoder);
|
||||||
|
result = gst_x265_enc_init_encoder_locked (encoder);
|
||||||
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* gst_x265_enc_close_encoder
|
/* gst_x265_enc_close_encoder
|
||||||
* @encoder: Encoder which should close.
|
* @encoder: Encoder which should close.
|
||||||
*
|
*
|
||||||
|
@ -1520,7 +1525,7 @@ gst_x265_enc_encode_frame (GstX265Enc * encoder, x265_picture * pic_in,
|
||||||
GST_OBJECT_LOCK (encoder);
|
GST_OBJECT_LOCK (encoder);
|
||||||
if (encoder->reconfig) {
|
if (encoder->reconfig) {
|
||||||
/* x265_encoder_reconfig is not yet implemented thus we shut down and re-create encoder */
|
/* x265_encoder_reconfig is not yet implemented thus we shut down and re-create encoder */
|
||||||
gst_x265_enc_init_encoder (encoder);
|
gst_x265_enc_init_encoder_locked (encoder);
|
||||||
update_latency = TRUE;
|
update_latency = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue