From 0793df89e4a018c6abe662181a564ec137b2487a Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 19 Jan 2026 20:38:29 -0800 Subject: use tmpfs for bgra images, delete on shutdown --- osd.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'osd.lua') diff --git a/osd.lua b/osd.lua index 2cd1be2..3be5e2d 100644 --- a/osd.lua +++ b/osd.lua @@ -19,6 +19,10 @@ for k, v in pairs(config.colours) do colours[k] = '{\\c&H' .. tag end +local bgra_file = mp_utils.join_path( + config.tmp_dir, + mp.get_script_name() .. '-' .. mp_utils.getpid() .. '.bgra') + local function draw_rect(x1, y1, x2, y2) return string.format( '{\\p1}m %f %f l %f %f %f %f %f %f{\\p0}', @@ -57,6 +61,16 @@ function osd.new(init) return t end +function mt:destroy() + if self.magick_cmd_id then + mp.abort_async_command(self.magick_cmd_id) + end + + if mp_utils.file_info(bgra_file) then + os.remove(bgra_file) + end +end + function mt:dirty() self.is_dirty = true end @@ -256,7 +270,7 @@ function mt:load_img() self.img.min_h, self.img.min_w, self.img.max_h, self.img.max_w), '-print', '%w %h', - 'tmp.bgra' + bgra_file } print('exec: ' .. mp_utils.to_string(magick_cmd)) self.img.magick_cmd = magick_cmd @@ -289,7 +303,7 @@ function mt:load_img() self.img.cmd = { name = 'overlay-add', id = 0, - file = 'tmp.bgra', + file = bgra_file, w = w, h = h, x = self.img.right - w, -- cgit v1.2.3-70-g09d2