summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-27 02:33:51 +0100
committerwm4 <wm4@nowhere>2020-02-27 02:33:51 +0100
commitc4440db7448ab8b64103af46e7ffb38e3e57bc0e (patch)
treeb5265b4889ff2345646b77dde8bc6e219a5f274e
parent423323170b01794084beb1d9993a10d8da84952b (diff)
downloadmpv-c4440db7448ab8b64103af46e7ffb38e3e57bc0e.tar.bz2
mpv-c4440db7448ab8b64103af46e7ffb38e3e57bc0e.tar.xz
sub: do not ignore demuxer wakeups
Setting demux_set_stream_wakeup_cb() will make all sh_stream (i.e. track) specific wakeups go to this callback. But the callback takes care of only the sub_preload() case (where it tries to pre-load subtitles from already parsed and memory-present subtitles in a blocking way). The old code assumed that the normal demuxer wakeup callback is called. This was disregarded when the newer code was added. (And actually, the original plan was to make _all_ per-sh_stream wakeups go to specialized callbacks to avoid wasted work. dec_sub really should set the callback always, and propagate wakeups to the playloop code. But it's too far into the night to write coherent code.) I couldn't actually observe any manifestation of this bug. Normally, the playloop wakes up for other reasons (such as driving audio and video decoding), so the lost wakeups rarely matter.
-rw-r--r--sub/dec_sub.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index fcaebedd1b..430f8aefbe 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -71,8 +71,6 @@ struct dec_sub {
struct sd *sd;
struct demux_packet *new_segment;
-
- struct mp_dispatch_queue *demux_waiter;
};
static void update_subtitle_speed(struct dec_sub *sub)
@@ -192,13 +190,10 @@ struct dec_sub *sub_create(struct mpv_global *global, struct sh_stream *sh,
.last_vo_pts = MP_NOPTS_VALUE,
.start = MP_NOPTS_VALUE,
.end = MP_NOPTS_VALUE,
- .demux_waiter = mp_dispatch_create(sub),
};
sub->opts = sub->opts_cache->opts;
mpthread_mutex_init_recursive(&sub->lock);
- demux_set_stream_wakeup_cb(sub->sh, wakeup_demux, sub->demux_waiter);
-
sub->sd = init_decoder(sub);
if (sub->sd) {
update_subtitle_speed(sub);
@@ -251,13 +246,16 @@ void sub_preload(struct dec_sub *sub)
{
pthread_mutex_lock(&sub->lock);
+ struct mp_dispatch_queue *demux_waiter = mp_dispatch_create(NULL);
+ demux_set_stream_wakeup_cb(sub->sh, wakeup_demux, demux_waiter);
+
sub->preload_attempted = true;
for (;;) {
struct demux_packet *pkt = NULL;
int r = demux_read_packet_async(sub->sh, &pkt);
if (r == 0) {
- mp_dispatch_queue_process(sub->demux_waiter, INFINITY);
+ mp_dispatch_queue_process(demux_waiter, INFINITY);
continue;
}
if (!pkt)
@@ -266,6 +264,9 @@ void sub_preload(struct dec_sub *sub)
talloc_free(pkt);
}
+ demux_set_stream_wakeup_cb(sub->sh, NULL, NULL);
+ talloc_free(demux_waiter);
+
pthread_mutex_unlock(&sub->lock);
}