From 261506e36edd88dd1b92ead93868bb624ddcf324 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 28 Jul 2014 20:40:43 +0200 Subject: audio: change playback restart and resyncing This commit makes audio decoding non-blocking. If e.g. the network is too slow the playloop will just go to sleep, instead of blocking until enough data is available. For video, this was already done with commit 7083f88c. For audio, it's unfortunately much more complicated, because the audio decoder was used in a blocking manner. Large changes are required to get around this. The whole playback restart mechanism must be turned into a statemachine, especially since it has close interactions with video restart. Lots of video code is thus also changed. (For the record, I don't think switching this code to threads would make this conceptually easier: the code would still have to deal with external input while blocked, so these in-between states do get visible [and thus need to be handled] anyway. On the other hand, it certainly should be possible to modularize this code a bit better.) This will probably cause a bunch of regressions. --- audio/decode/ad_spdif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'audio/decode/ad_spdif.c') diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index c215f92e63..528e42fbc4 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -191,7 +191,10 @@ static int decode_packet(struct dec_audio *da) spdif_ctx->out_buffer_len = 0; - struct demux_packet *mpkt = demux_read_packet(da->header); + struct demux_packet *mpkt; + if (demux_read_packet_async(da->header, &mpkt) == 0) + return AD_WAIT; + if (!mpkt) return AD_EOF; -- cgit v1.2.3