From 334cad57c63d31a346b1457ae92dbb0b64938016 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jan 2017 12:14:04 +0100 Subject: demux: rename a function Also extend the comment on it. --- demux/demux.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index 4b6536ef29..a94d98e10f 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -798,13 +798,17 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds) return pkt; } +// Whether to avoid actively demuxing new packets to find a new packet on the +// given stream. // Sparse packets (Subtitles) interleaved with other non-sparse packets (video, // audio) should never be read actively, meaning the demuxer thread does not // try to exceed default readahead in order to find a new packet. -static bool use_lazy_subtitle_reading(struct demux_stream *ds) +static bool use_lazy_packet_reading(struct demux_stream *ds) { if (ds->type != STREAM_SUB) return false; + // Subtitles are only lazily read if there's at least 1 other actively read + // stream. for (int n = 0; n < ds->in->num_streams; n++) { struct demux_stream *s = ds->in->streams[n]->ds; if (s->type != STREAM_SUB && s->selected && !s->eof) @@ -823,7 +827,7 @@ struct demux_packet *demux_read_packet(struct sh_stream *sh) if (ds) { struct demux_internal *in = ds->in; pthread_mutex_lock(&in->lock); - if (!use_lazy_subtitle_reading(ds)) { + if (!use_lazy_packet_reading(ds)) { const char *t = stream_type_name(ds->type); MP_DBG(in, "reading packet for %s\n", t); in->eof = false; // force retry @@ -869,7 +873,7 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt) if (ds->in->threading) { pthread_mutex_lock(&ds->in->lock); *out_pkt = dequeue_packet(ds); - if (use_lazy_subtitle_reading(ds)) { + if (use_lazy_packet_reading(ds)) { r = *out_pkt ? 1 : -1; } else { r = *out_pkt ? 1 : ((ds->eof || !ds->selected) ? -1 : 0); -- cgit v1.2.3