[Spice-devel] [spice v13 10/29] server: Handle and recover from GStreamer encoding errors

Christophe Fergeau cfergeau at redhat.com
Fri Jun 3 15:08:37 UTC 2016


On Wed, May 04, 2016 at 11:21:13AM +0200, Francois Gouget wrote:
> On Tue, 3 May 2016, Christophe Fergeau wrote:
> [...]
> > And GStreamer GstBus/GstAppSink API tends to be async, while we need
> > encode_frame() to be sync, so there is indeed several useful APIs that
> > we cannot use without additional complexity. I'm wondering if the
> > simpler patch attached to this message could work too.
> 
> I had tried that but while it works you get a big warning that changing 
> the state of the pipeline from the streaming thread is not allowed:
> 
> (Xorg:29234): Spice-WARNING **: gstreamer-encoder.c:809:handle_pipeline_message: GStreamer error from element encoder: Can not initialize x264 encoder.
> gstreamer-encoder.c:809:handle_pipeline_message: GStreamer error from element encoder: Can not initialize x264 encoder.
> gstreamer-encoder.c:811:handle_pipeline_message: debug details: gstx264enc.c(1269): gst_x264_enc_init_encoder (): /GstPipeline:pipeline3/GstX264Enc:encoder
> 0:00:09.382605905 29234 0x7f3de0855e80 DEBUG             GST_STATES gstelement.c:2638:gst_element_set_state_func:<pipeline3> set_state to NULL
> [...]
> 0:00:09.384261060 29234 0x7f3de0855e80 WARN                    task gsttask.c:862:gst_task_join:<src:src> trying to join task from its thread
> 
> (Xorg:29234): GStreamer-WARNING **: 
> Trying to join task 0x7f3de00f7560 from its thread would deadlock.
> You cannot change the state of an element from its streaming
> thread. Use g_idle_add() or post a GstMessage on the bus to
> schedule the state change from the main thread.
> 
> 0:00:09.384286706 29234 0x7f3de0855e80 DEBUG               GST_PADS gstpad.c:5731:gst_pad_stop_task:<src:src> join failed
> 0:00:09.384291170 29234 0x7f3de0855e80 DEBUG                basesrc gstbasesrc.c:2854:gst_base_src_stop:<src> stopping source

For what it's worth, I tried asking GStreamer people if they had
suggestions how we could handle what is being done in this patch, but
they did not have a silver bullet :)
Suggestions included running our own mainloop/maincontext in
encode_frame(), but this would probably be not much different than
having the GCond.
Another option would be a slight variation on this patch which led to
the warnings above ("cannot set pipeline state from streaming thread"):
rather than calling gst_element_set_state() directly, call
g_thread_new(function_calling_gst_element_set_state). I think this could
work, but haven't been lucky in reproducing the initial bug/this warning
:(

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160603/c16f9967/attachment-0001.sig>


More information about the Spice-devel mailing list