diff options
-rw-r--r-- | player/loadfile.c | 6 | ||||
-rw-r--r-- | sub/dec_sub.h | 1 | ||||
-rw-r--r-- | sub/sd_ass.c | 16 |
3 files changed, 19 insertions, 4 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index af60aed3e0..8b35209d9f 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -336,6 +336,12 @@ bool timeline_switch_to_time(struct MPContext *mpctx, double pts) track->type, track->user_tid - 1); } + + if (track->type == STREAM_SUB && track->stream) { + struct dec_sub *dec = track->stream->sub->dec_sub; + if (dec) + sub_control(dec, SD_CTRL_CLEAR, NULL); + } } } diff --git a/sub/dec_sub.h b/sub/dec_sub.h index 40a882c9f0..53b42e484e 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -22,6 +22,7 @@ enum sd_ctrl { SD_CTRL_SET_VIDEO_PARAMS, SD_CTRL_GET_RESOLUTION, SD_CTRL_SET_TOP, + SD_CTRL_CLEAR, }; struct dec_sub *sub_create(struct mpv_global *global); diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 16275207b7..88aebe8c6a 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -510,13 +510,18 @@ static void fill_plaintext(struct sd *sd, double pts) track->styles[track->default_style].Alignment = ctx->on_top ? 6 : 2; } +static void clear(struct sd *sd) +{ + struct sd_ass_priv *ctx = sd->priv; + ass_flush_events(ctx->ass_track); + ctx->num_seen_packets = 0; +} + static void reset(struct sd *sd) { struct sd_ass_priv *ctx = sd->priv; - if (sd->opts->sub_clear_on_seek) { - ass_flush_events(ctx->ass_track); - ctx->num_seen_packets = 0; - } + if (sd->opts->sub_clear_on_seek) + clear(sd); if (ctx->converter) lavc_conv_reset(ctx->converter); } @@ -549,6 +554,9 @@ static int control(struct sd *sd, enum sd_ctrl cmd, void *arg) case SD_CTRL_SET_TOP: ctx->on_top = *(bool *)arg; return CONTROL_OK; + case SD_CTRL_CLEAR: + clear(sd); + return CONTROL_OK; default: return CONTROL_UNKNOWN; } |