summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-10 12:14:04 +0100
committerwm4 <wm4@nowhere>2017-01-10 12:27:37 +0100
commit334cad57c63d31a346b1457ae92dbb0b64938016 (patch)
tree2a18f8b6f3b44979e10733ccce05f697d87da3e9
parent0e8b9ed2283210c946a5d48310372b52adaf64df (diff)
downloadmpv-334cad57c63d31a346b1457ae92dbb0b64938016.tar.bz2
mpv-334cad57c63d31a346b1457ae92dbb0b64938016.tar.xz
demux: rename a function
Also extend the comment on it.
-rw-r--r--demux/demux.c10
1 files changed, 7 insertions, 3 deletions
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);