From 7083f88ca8b98aa74dbc9e34d5c5cf6e150cfe0b Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 Jul 2014 15:10:28 +0200 Subject: video: don't block when reading video packets Instead of blocking on the demuxer when reading a packet, let packets be read asynchronously. Basically, it polls whether a packet is available, and if not, the playloop goes to sleep until the demuxer thread wakes it up. Note that the player will still block for I/O, because audio is still read synchronously. It's much harder to do the same change for audio (because of the design of the audio decoding path and especially initialization), so audio will have to be done later. --- player/playloop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'player/playloop.c') diff --git a/player/playloop.c b/player/playloop.c index 2392fd32a4..a3fcf133e3 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -985,6 +985,12 @@ void run_playloop(struct MPContext *mpctx) video_left = r > 0; + if (r == 3) + break; + + if (mpctx->restart_playback) + mpctx->sleeptime = 0; + if (r == 2) MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time); @@ -1243,9 +1249,6 @@ void run_playloop(struct MPContext *mpctx) if (mpctx->stop_play) mpctx->sleeptime = 0; - if (mpctx->restart_playback) - mpctx->sleeptime = 0; - if (mpctx->sleeptime > 0 && handle_osd_redraw(mpctx)) mpctx->sleeptime = 0; -- cgit v1.2.3