diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-09-28 20:07:43 -0400 |
---|---|---|
committer | Josep Torra <n770galaxy@gmail.com> | 2013-03-10 11:48:41 +0100 |
commit | deb7f9600492535ca6db4d7000a37038c6119d02 (patch) | |
tree | babd317a9c2ce6716cb5a3fdb8a7dfe8ff1d75a8 | |
parent | a1eff875bf5d5c7c88da46b1373461bd71c87189 (diff) | |
download | gstreamer-plugins-base-deb7f9600492535ca6db4d7000a37038c6119d02.tar.gz |
videodecoder: Also use the object lock to protect the output_state
Hold both the stream and the object lock to modify the output_state,
this way it can be safely modified while hold either one or the other.
Also, only hold the object lock in the query
https://bugzilla.gnome.org/show_bug.cgi?id=684832
-rw-r--r-- | gst-libs/gst/video/gstvideodecoder.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index fa999d656..6104f4b2e 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -383,7 +383,7 @@ struct _GstVideoDecoderPrivate GList *frames; /* Protected with OBJECT_LOCK */ GstVideoCodecState *input_state; - GstVideoCodecState *output_state; + GstVideoCodecState *output_state; /* OBJECT_LOCK and STREAM_LOCK */ gboolean output_state_changed; /* QoS properties */ @@ -1335,13 +1335,13 @@ gst_video_decoder_src_query (GstPad * pad, GstQuery * query) GST_DEBUG_OBJECT (dec, "convert query"); gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val); - GST_VIDEO_DECODER_STREAM_LOCK (dec); + GST_OBJECT_LOCK (dec); if (dec->priv->output_state != NULL) res = gst_video_rawvideo_convert (dec->priv->output_state, src_fmt, src_val, &dest_fmt, &dest_val); else res = FALSE; - GST_VIDEO_DECODER_STREAM_UNLOCK (dec); + GST_OBJECT_UNLOCK (dec); if (!res) goto error; gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val); @@ -1538,11 +1538,11 @@ gst_video_decoder_reset (GstVideoDecoder * decoder, gboolean full) if (priv->input_state) gst_video_codec_state_unref (priv->input_state); priv->input_state = NULL; + GST_OBJECT_LOCK (decoder); if (priv->output_state) gst_video_codec_state_unref (priv->output_state); priv->output_state = NULL; - GST_OBJECT_LOCK (decoder); priv->qos_frame_duration = 0; GST_OBJECT_UNLOCK (decoder); @@ -2558,10 +2558,10 @@ gst_video_decoder_get_output_state (GstVideoDecoder * decoder) { GstVideoCodecState *state = NULL; - GST_VIDEO_DECODER_STREAM_LOCK (decoder); + GST_OBJECT_LOCK (decoder); if (decoder->priv->output_state) state = gst_video_codec_state_ref (decoder->priv->output_state); - GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); + GST_OBJECT_UNLOCK (decoder); return state; } @@ -2600,7 +2600,6 @@ gst_video_decoder_set_output_state (GstVideoDecoder * decoder, { GstVideoDecoderPrivate *priv = decoder->priv; GstVideoCodecState *state; - GstClockTime qos_frame_duration; GST_DEBUG_OBJECT (decoder, "fmt:%d, width:%d, height:%d, reference:%p", fmt, width, height, reference); @@ -2609,25 +2608,25 @@ gst_video_decoder_set_output_state (GstVideoDecoder * decoder, state = _new_output_state (fmt, width, height, reference); GST_VIDEO_DECODER_STREAM_LOCK (decoder); + + GST_OBJECT_LOCK (decoder); /* Replace existing output state by new one */ if (priv->output_state) gst_video_codec_state_unref (priv->output_state); priv->output_state = gst_video_codec_state_ref (state); if (priv->output_state != NULL && priv->output_state->info.fps_n > 0) { - qos_frame_duration = + priv->qos_frame_duration = gst_util_uint64_scale (GST_SECOND, priv->output_state->info.fps_d, priv->output_state->info.fps_n); } else { - qos_frame_duration = 0; + priv->qos_frame_duration = 0; } priv->output_state_changed = TRUE; - GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); - - GST_OBJECT_LOCK (decoder); - priv->qos_frame_duration = qos_frame_duration; GST_OBJECT_UNLOCK (decoder); + GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); + return state; } |