Commit fc7e6b19 authored by Olivier Crête's avatar Olivier Crête 👻 Committed by Sreerenj Balachandran

vaapidecode: Check the condition after taking the lock

Otherwise the condition could become true before the lock
is taken and the g_cond_signal() could be called
before the g_cond_wait(), so the g_cond_wait() is never
awoken.

https://bugzilla.gnome.org/show_bug.cgi?id=740645
parent d2e2784a
......@@ -129,6 +129,9 @@ gst_vaapi_decoder_decode (GstVaapiDecoder * decoder,
GstVaapiDecoderStatus
gst_vaapi_decoder_flush (GstVaapiDecoder * decoder);
GstVaapiDecoderStatus
gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder);
G_END_DECLS
#endif /* GST_VAAPI_DECODER_H */
......@@ -273,10 +273,6 @@ void
gst_vaapi_decoder_push_frame (GstVaapiDecoder * decoder,
GstVideoCodecFrame * frame);
G_GNUC_INTERNAL
GstVaapiDecoderStatus
gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder);
G_GNUC_INTERNAL
GstVaapiDecoderStatus
gst_vaapi_decoder_decode_codec_data (GstVaapiDecoder * decoder);
......
......@@ -235,13 +235,16 @@ gst_vaapidecode_decode_frame(GstVideoDecoder *vdec, GstVideoCodecFrame *frame)
GstVaapiDecoderStatus status;
GstFlowReturn ret;
/* Decode current frame */
for (;;) {
status = gst_vaapi_decoder_decode(decode->decoder, frame);
if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE) {
GST_VIDEO_DECODER_STREAM_UNLOCK(vdec);
g_mutex_lock(&decode->decoder_mutex);
g_cond_wait(&decode->decoder_ready, &decode->decoder_mutex);
if (gst_vaapi_decoder_check_status (decode->decoder) ==
GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE)
g_cond_wait(&decode->decoder_ready, &decode->decoder_mutex);
g_mutex_unlock(&decode->decoder_mutex);
GST_VIDEO_DECODER_STREAM_LOCK(vdec);
if (decode->decoder_loop_status < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment