summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}