vaapiencoder: (baseclass): wrap in a while loop g_cond_wait() as documented
Submitted by Ahmed K
Link to original bug (#796539)
Description
Created attachment 372602
Screenshot of gstreamer's log
I developed streaming application with gstreamer-1.10.4 and used vaapi to accelerate decoding/encoding. It streams video encoded to ts stream with h264 format.
But streaming stops after random period of time when it is started.
Constantly I get error gst_vaapi_encoder_put_frame: failed to allocate coded buffer and gst_vaapiencode_handle_frame: failed to encode frame xxx (status -2).
After some debugging I found the reason for this. It seems that problem is in gst_vaapi_encoder_create_coded_buffer function in gstvaapiencoder.c.
In this line g_cond_wait (&encoder->codedbuf_free, &encoder->mutex); should be placed in loop as spurious wakeup can occur. This is explained in glib documentation: https://developer.gnome.org/glib/stable/glib-Threads.html#g-cond-wait .
I putted g_cond_wait with codedbuf_proxy check in a loop and forced it to retry and wait for the buffer to be available. Then I recompilled gstreamer-vaapi. Now it works perfectly without stopping.
I can submit a patch on request.
Attachment 372602, "Screenshot of gstreamer's log":
Version: 1.x