summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-18 18:25:14 +0100
committerwm4 <wm4@nowhere>2016-01-18 18:43:18 +0100
commitf15a79d14467d8c30dcaffa53d8871ef01b9328e (patch)
tree9d66a19c0176966c469374f4f5b43e44d2bfe95b
parent488f569d9956d12e8ac5db79cf5959f015b4f8d0 (diff)
downloadmpv-f15a79d14467d8c30dcaffa53d8871ef01b9328e.tar.bz2
mpv-f15a79d14467d8c30dcaffa53d8871ef01b9328e.tar.xz
demux: fix interleaved subtitle reading in unthreaded mode
Meh. Why are there even two code paths. This adds an additional check; the big function is only moved.
-rw-r--r--demux/demux.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 4fedc69e60..de59a6dc28 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -667,6 +667,21 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds)
return pkt;
}
+// 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)
+{
+ if (ds->type != STREAM_SUB)
+ return false;
+ 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)
+ return true;
+ }
+ return false;
+}
+
// Read a packet from the given stream. The returned packet belongs to the
// caller, who has to free it with talloc_free(). Might block. Returns NULL
// on EOF.
@@ -676,7 +691,8 @@ struct demux_packet *demux_read_packet(struct sh_stream *sh)
struct demux_packet *pkt = NULL;
if (ds) {
pthread_mutex_lock(&ds->in->lock);
- ds_get_packets(ds);
+ if (!use_lazy_subtitle_reading(ds))
+ ds_get_packets(ds);
pkt = dequeue_packet(ds);
pthread_cond_signal(&ds->in->wakeup); // possibly read more
pthread_mutex_unlock(&ds->in->lock);
@@ -684,21 +700,6 @@ struct demux_packet *demux_read_packet(struct sh_stream *sh)
return pkt;
}
-// 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)
-{
- if (ds->type != STREAM_SUB)
- return false;
- 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)
- return true;
- }
- return false;
-}
-
// Poll the demuxer queue, and if there's a packet, return it. Otherwise, just
// make the demuxer thread read packets for this stream, and if there's at
// least one packet, call the wakeup callback.