path: root/player
diff options
authorwm4 <wm4@nowhere>2015-01-10 00:41:37 +0100
committerwm4 <wm4@nowhere>2015-01-10 00:41:45 +0100
commit69dad662c9a3d251792affbac38b9df7e02245f9 (patch)
treedb7a531f51aed1bb3c62eae32df67027fe878520 /player
parent23e4a8ce7f833b551b808a850c1be759df4ab2ef (diff)
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.
Diffstat (limited to 'player')
1 files changed, 9 insertions, 0 deletions
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);
+ 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);
+ }
+ }