From 190dea149aea07bc4be41c684a50db4231ccb0da Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 26 Dec 2015 18:35:36 +0100 Subject: sub: destroy/recreate ASS_Renderer when disabling/enablings subs Keeping ASS_Renderers around for a potentially large number of subtitle tracks could lead to excessive memory usage, especially since the libass cache is broken (caches even unneeded data), and might consume up to ~500MB of memory for no reason. --- player/sub.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'player/sub.c') diff --git a/player/sub.c b/player/sub.c index 9c69df39ab..059dbdc2fd 100644 --- a/player/sub.c +++ b/player/sub.c @@ -55,6 +55,7 @@ void uninit_sub(struct MPContext *mpctx, int order) { if (mpctx->d_sub[order]) { reset_subtitles(mpctx, order); + sub_select(mpctx->d_sub[order], false); mpctx->d_sub[order] = NULL; // not destroyed osd_set_sub(mpctx->osd, OSDTYPE_SUB + order, NULL); reselect_demux_streams(mpctx); @@ -183,6 +184,7 @@ void reinit_subs(struct MPContext *mpctx, int order) track->dec_sub = sub_create(mpctx->global); mpctx->d_sub[order] = track->dec_sub; + sub_select(track->dec_sub, true); reinit_subdec(mpctx, track); osd_set_sub(mpctx->osd, OSDTYPE_SUB + order, track->dec_sub); sub_control(track->dec_sub, SD_CTRL_SET_TOP, &(bool){!!order}); -- cgit v1.2.3