mirror of
https://github.com/mpv-player/mpv
synced 2025-02-06 15:11:58 +00:00
demux: rename a function
Also extend the comment on it.
This commit is contained in:
parent
0e8b9ed228
commit
334cad57c6
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user