mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
videodecoder: Use the object lock to protect bytes/time tracking
And especially don't use the stream lock for that, as otherwise non-serialized queries (CONVERT) will cause the stream lock to be taken and easily causes the application to deadlock. https://bugzilla.gnome.org/show_bug.cgi?id=768361
This commit is contained in:
parent
3cabd3fe55
commit
66342c5c86
1 changed files with 13 additions and 3 deletions
|
@ -1385,8 +1385,14 @@ gst_video_decoder_sink_event (GstPad * pad, GstObject * parent,
|
|||
static inline gboolean
|
||||
gst_video_decoder_do_byte (GstVideoDecoder * dec)
|
||||
{
|
||||
return dec->priv->do_estimate_rate && (dec->priv->bytes_out > 0)
|
||||
gboolean ret;
|
||||
|
||||
GST_OBJECT_LOCK (dec);
|
||||
ret = dec->priv->do_estimate_rate && (dec->priv->bytes_out > 0)
|
||||
&& (dec->priv->time > GST_SECOND);
|
||||
GST_OBJECT_UNLOCK (dec);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1766,11 +1772,11 @@ gst_video_decoder_sink_query_default (GstVideoDecoder * decoder,
|
|||
gint64 src_val, dest_val;
|
||||
|
||||
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
|
||||
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
|
||||
GST_OBJECT_LOCK (decoder);
|
||||
res =
|
||||
__gst_video_encoded_video_convert (priv->bytes_out, priv->time,
|
||||
src_fmt, src_val, &dest_fmt, &dest_val);
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
|
||||
GST_OBJECT_UNLOCK (decoder);
|
||||
if (!res)
|
||||
goto error;
|
||||
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
|
||||
|
@ -2053,8 +2059,10 @@ gst_video_decoder_reset (GstVideoDecoder * decoder, gboolean full,
|
|||
g_list_free_full (priv->timestamps, (GDestroyNotify) timestamp_free);
|
||||
priv->timestamps = NULL;
|
||||
|
||||
GST_OBJECT_LOCK (decoder);
|
||||
priv->bytes_out = 0;
|
||||
priv->time = 0;
|
||||
GST_OBJECT_UNLOCK (decoder);
|
||||
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
|
||||
}
|
||||
|
@ -3125,6 +3133,7 @@ gst_video_decoder_clip_and_push_buf (GstVideoDecoder * decoder, GstBuffer * buf)
|
|||
}
|
||||
|
||||
/* update rate estimate */
|
||||
GST_OBJECT_LOCK (decoder);
|
||||
priv->bytes_out += gst_buffer_get_size (buf);
|
||||
if (GST_CLOCK_TIME_IS_VALID (duration)) {
|
||||
priv->time += duration;
|
||||
|
@ -3135,6 +3144,7 @@ gst_video_decoder_clip_and_push_buf (GstVideoDecoder * decoder, GstBuffer * buf)
|
|||
/* better none than nothing valid */
|
||||
priv->time = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
GST_OBJECT_UNLOCK (decoder);
|
||||
|
||||
GST_DEBUG_OBJECT (decoder, "pushing buffer %p of size %" G_GSIZE_FORMAT ", "
|
||||
"PTS %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT, buf,
|
||||
|
|
Loading…
Reference in a new issue