]> git.sesse.net Git - vlc/commit
omxil: Use vlc_cond_timedwait when waiting for free input buffers
authorMartin Storsjö <martin@martin.st>
Tue, 12 Feb 2013 09:37:33 +0000 (11:37 +0200)
committerMartin Storsjö <martin@martin.st>
Tue, 12 Feb 2013 09:53:34 +0000 (11:53 +0200)
commitbbf8c217d96e344fd5c5757cae1a599fc2eabbdd
tree457c2b64c6cf4d80d25d5f1feaae871b6b736ab1
parent356c37db5dfdf9da3a10a2318bebc8783cfed019
omxil: Use vlc_cond_timedwait when waiting for free input buffers

The structure of the decode functions are like this:

Decode() {
    if (got output buffer) {
        consume output buffer;
    }
    wait for input buffer;
    if (got input buffer) {
        fill input buffer and send to the codec;
    }
}

This makes the functions prone to deadlock, if all input buffers
have been consumed and won't be returned by the codec until we
consume some of the output buffers (and we don't get the output
buffers until we already are waiting for an input buffer).

By using a timeout in the wait for input buffers, we get out of the
deadlock and can consume an output buffer, allowing the codec to
proceed. By making the timeout relatively large, it won't trigger
during normal decoding, but gets us out of possible deadlocks
(noticed at startup with qualcomm audio decoders).

The alternative to timeouts would be to push dummy/sentinel buffers
into the fifo (as we already do at reconfiguration) each time we
receive an output buffer. This would add quite a bit of overhead
though, having to process (and skip) one item in the input buffer
fifo for each received output buffer.

Signed-off-by: Martin Storsjö <martin@martin.st>
modules/codec/omxil/omxil.c
modules/codec/omxil/omxil_utils.h