[vlc-devel] [PATCH 2/2] decoder: fix input_DecoderWait deadlock

Thomas Guillem thomas at gllm.fr
Tue Dec 15 11:15:42 CET 2015


On Tue, Dec 15, 2015, at 10:46, Rémi Denis-Courmont wrote:
> Le 2015-12-11 15:17, Thomas Guillem a écrit :
> > I don't feely ready to get rid of input_DecoderWait and rewrite 
> > es_out, at
> > least, not for 3.0.
> 
> So you are giving up on asynchronous decoding then?

No,

> 
> input_DecoderWait() waits for the decoder thread to output some decoded 
> content. There is a corner case whereby the decoder thread drains its 
> entire input FIFO without outputting anything. In that case, 
> input_DecoderWait() would deadlock. So it gets short-circuited. There is 
> currently a race condition in this exact situation. It can lead to the 
> deadlock that you are trying to address.
> 
> With the new asynchronous decoding, the "corner case" becomes the norm. 
> The decoder thread never outputs anything, and the decoded content comes 
> from other private threads of the decoder plugin at an arbitrary point 
> in time. input_DecoderWait() gets short-circuited all the time. In other 
> words, it does not work.
> 
> So the questions are:
> 
> 1) Is input_DecoderWait() useful anymore?

I tried first to remove it, but I was afraid of unknown repercussions.
Without it, I got a lot of frame drop with avcodec after a flush. I need
to investigate more on this.

> 
> 2) If so, how do you fix it the empty FIFO case? Especially 
> asynchronous decoding.

The empty FIFO case is fixed by this patch, but in a ugly way I agree.

By the way, the mediacodec asynchronous decoder process input blocks
synchronously. Only output buffers are processed asynchronously. When I
first implemented asynchronous mediacodec, I tried to also process input
blocks asynchronously. But if you do so, you double the input cache, and
you got a lot of delay when seeking.

That's why I don't think a decoder module should process input blocks
asynchronously.

> 
> 3) If not so, is it not much easier to remove input_DecoderWait()?
> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list