From 69dad662c9a3d251792affbac38b9df7e02245f9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 10 Jan 2015 00:41:37 +0100 Subject: player: enable demuxer thread for external audio files Enable asynchronous reading for external files. This excludes subtitle files (so it's effectively enabled for audio files only), because most subtitle files are fully read on loading, and running a thread for them would just cause slowdowns and increase resource usage, without having any advantages. In theory, an external file could provide multiple tracks from the same demuxer, but demux_start_thread() is idempotent, so the code can be kept simple. Should help with playing DASH with ytdl_hook. --- player/loadfile.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'player') diff --git a/player/loadfile.c b/player/loadfile.c index 5be2abb806..bd46983837 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -258,6 +258,15 @@ static void enable_demux_thread(struct MPContext *mpctx) if (mpctx->demuxer && mpctx->opts->demuxer_thread) { demux_set_wakeup_cb(mpctx->demuxer, wakeup_demux, mpctx); demux_start_thread(mpctx->demuxer); + for (int n = 0; n < mpctx->num_tracks; n++) { + struct track *track = mpctx->tracks[n]; + if (track->is_external && track->stream && + track->stream->type != STREAM_SUB) + { + demux_set_wakeup_cb(track->demuxer, wakeup_demux, mpctx); + demux_start_thread(track->demuxer); + } + } } } -- cgit v1.2.3