1
mirror of https://github.com/mpv-player/mpv synced 2024-11-14 22:48:35 +01:00

Revert "demux: eagerly read subtitle streams when switching tracks while paused"

Actually, I thought of a better way of handling this shortly after
merging this. Revert it and redo it in the next commit.

This reverts commit c2c157ebec.
This commit is contained in:
Dudemanguy 2023-09-27 21:51:49 -05:00
parent c2c157ebec
commit 09b04fbf09
3 changed files with 5 additions and 10 deletions

View File

@ -2767,7 +2767,7 @@ static int dequeue_packet(struct demux_stream *ds, double min_pts,
// minutes away). In this situation, this function will just return -1. // minutes away). In this situation, this function will just return -1.
int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt) int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
{ {
return demux_read_packet_async_until(sh, MP_NOPTS_VALUE, out_pkt, false); return demux_read_packet_async_until(sh, MP_NOPTS_VALUE, out_pkt);
} }
// Like demux_read_packet_async(). They are the same for min_pts==MP_NOPTS_VALUE. // Like demux_read_packet_async(). They are the same for min_pts==MP_NOPTS_VALUE.
@ -2775,25 +2775,20 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt)
// subtitles), then return 0 until demuxing has reached min_pts, or the queue // subtitles), then return 0 until demuxing has reached min_pts, or the queue
// overflowed, or EOF was reached, or a packet was read for this stream. // overflowed, or EOF was reached, or a packet was read for this stream.
int demux_read_packet_async_until(struct sh_stream *sh, double min_pts, int demux_read_packet_async_until(struct sh_stream *sh, double min_pts,
struct demux_packet **out_pkt, bool force_eager) struct demux_packet **out_pkt)
{ {
struct demux_stream *ds = sh ? sh->ds : NULL; struct demux_stream *ds = sh ? sh->ds : NULL;
*out_pkt = NULL; *out_pkt = NULL;
if (!ds) if (!ds)
return -1; return -1;
if (force_eager)
ds->eager = true;
struct demux_internal *in = ds->in; struct demux_internal *in = ds->in;
pthread_mutex_lock(&in->lock); pthread_mutex_lock(&in->lock);
int r = -1; int r = -1;
while (1) { while (1) {
r = dequeue_packet(ds, min_pts, out_pkt); r = dequeue_packet(ds, min_pts, out_pkt);
if (in->threading || in->blocked || r != 0) { if (in->threading || in->blocked || r != 0)
if (force_eager)
ds->eager = false;
break; break;
}
// Needs to actually read packets until we got a packet or EOF. // Needs to actually read packets until we got a packet or EOF.
thread_work(in); thread_work(in);
} }

View File

@ -284,7 +284,7 @@ void demuxer_feed_caption(struct sh_stream *stream, demux_packet_t *dp);
int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt); int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt);
int demux_read_packet_async_until(struct sh_stream *sh, double min_pts, int demux_read_packet_async_until(struct sh_stream *sh, double min_pts,
struct demux_packet **out_pkt, bool force_eager); struct demux_packet **out_pkt);
bool demux_stream_is_selected(struct sh_stream *stream); bool demux_stream_is_selected(struct sh_stream *stream);
void demux_set_stream_wakeup_cb(struct sh_stream *sh, void demux_set_stream_wakeup_cb(struct sh_stream *sh,
void (*cb)(void *ctx), void *ctx); void (*cb)(void *ctx), void *ctx);

View File

@ -294,7 +294,7 @@ bool sub_read_packets(struct dec_sub *sub, double video_pts, bool force)
double min_pts = sub->opts->sub_delay < 0 || force ? video_pts : MP_NOPTS_VALUE; double min_pts = sub->opts->sub_delay < 0 || force ? video_pts : MP_NOPTS_VALUE;
struct demux_packet *pkt; struct demux_packet *pkt;
int st = demux_read_packet_async_until(sub->sh, min_pts, &pkt, force); int st = demux_read_packet_async_until(sub->sh, min_pts, &pkt);
// Note: "wait" (st==0) happens with non-interleaved streams only, and // Note: "wait" (st==0) happens with non-interleaved streams only, and
// then we should stop the playloop until a new enough packet has been // then we should stop the playloop until a new enough packet has been
// seen (or the subtitle decoder's queue is full). This usually does not // seen (or the subtitle decoder's queue is full). This usually does not