mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 00:42:57 +00:00
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.
This commit is contained in:
parent
488f569d99
commit
f15a79d144
@ -667,23 +667,6 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds)
|
||||
return pkt;
|
||||
}
|
||||
|
||||
// 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.
|
||||
struct demux_packet *demux_read_packet(struct sh_stream *sh)
|
||||
{
|
||||
struct demux_stream *ds = sh ? sh->ds : NULL;
|
||||
struct demux_packet *pkt = NULL;
|
||||
if (ds) {
|
||||
pthread_mutex_lock(&ds->in->lock);
|
||||
ds_get_packets(ds);
|
||||
pkt = dequeue_packet(ds);
|
||||
pthread_cond_signal(&ds->in->wakeup); // possibly read more
|
||||
pthread_mutex_unlock(&ds->in->lock);
|
||||
}
|
||||
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.
|
||||
@ -699,6 +682,24 @@ static bool use_lazy_subtitle_reading(struct demux_stream *ds)
|
||||
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.
|
||||
struct demux_packet *demux_read_packet(struct sh_stream *sh)
|
||||
{
|
||||
struct demux_stream *ds = sh ? sh->ds : NULL;
|
||||
struct demux_packet *pkt = NULL;
|
||||
if (ds) {
|
||||
pthread_mutex_lock(&ds->in->lock);
|
||||
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);
|
||||
}
|
||||
return pkt;
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
Loading…
Reference in New Issue
Block a user