From 62f225ef9d6e30c286c6a94f3bef147f7114696c Mon Sep 17 00:00:00 2001 From: Zsolt Vadasz Date: Wed, 13 Jan 2021 16:59:08 +0100 Subject: sub/osd: hide secondary subtitles if secondary-sub-visibility is false --- sub/dec_sub.c | 5 +++++ sub/dec_sub.h | 2 +- sub/osd.c | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'sub') diff --git a/sub/dec_sub.c b/sub/dec_sub.c index ebf3ea35e7..607b97e582 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -449,3 +449,8 @@ void sub_set_play_dir(struct dec_sub *sub, int dir) sub->play_dir = dir; pthread_mutex_unlock(&sub->lock); } + +bool sub_is_secondary_visible(struct dec_sub *sub) +{ + return !!sub->opts->sec_sub_visibility; +} diff --git a/sub/dec_sub.h b/sub/dec_sub.h index f998b59f6b..542c24798f 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -10,7 +10,6 @@ struct sh_stream; struct mpv_global; struct demux_packet; struct mp_recorder_sink; - struct dec_sub; struct sd; @@ -52,6 +51,7 @@ void sub_reset(struct dec_sub *sub); void sub_select(struct dec_sub *sub, bool selected); void sub_set_recorder_sink(struct dec_sub *sub, struct mp_recorder_sink *sink); void sub_set_play_dir(struct dec_sub *sub, int dir); +bool sub_is_secondary_visible(struct dec_sub *sub); int sub_control(struct dec_sub *sub, enum sd_ctrl cmd, void *arg); diff --git a/sub/osd.c b/sub/osd.c index de63befe7f..f02693e921 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -290,9 +290,12 @@ static struct sub_bitmaps *render_object(struct osd_state *osd, check_obj_resize(osd, osdres, obj); - if (obj->type == OSDTYPE_SUB || obj->type == OSDTYPE_SUB2) { + if (obj->type == OSDTYPE_SUB) { if (obj->sub) res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts); + } else if (obj->type == OSDTYPE_SUB2) { + if (obj->sub && sub_is_secondary_visible(obj->sub)) + res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts); } else if (obj->type == OSDTYPE_EXTERNAL2) { if (obj->external2 && obj->external2->format) { res = sub_bitmaps_copy(NULL, obj->external2); // need to be owner -- cgit v1.2.3