etternagame / etterna

Advanced cross-platform rhythm game focused on keyboard play
https://etternaonline.com/
MIT License
475 stars 134 forks source link

Fix file leak in MovieTexture_FFMpeg.cpp #1176

Closed nico-abram closed 2 years ago

nico-abram commented 2 years ago

Fixes #1155

I tested this with 2 movies on screen at once to make sure I didn't break it for more than 1 movie at the same time by adding a second banner with a previous song to the TD selectmusic screen in wifetwirl.lua

Lua snippet ```lua local prevSong = nil t[#t + 1] = Def.Sprite { Name = "Banner2", InitCommand = function(self) self:x(120):y(121):halign(0):valign(0) self:scaletoclipped(capWideScale(get43size(384), 384), capWideScale(get43size(120), 120)):diffusealpha(1) end, MintyFreshCommand = function(self) if INPUTFILTER:IsBeingPressed("tab") then self:finishtweening():smooth(0.25):diffusealpha(0):sleep(0.2):queuecommand("ModifyBanner") else self:finishtweening():queuecommand("ModifyBanner") end end, ModifyBannerCommand = function(self) self:finishtweening() if song then local bnpath = GAMESTATE:GetCurrentSong():GetBannerPath() if not bnpath then bnpath = THEME:GetPathG("Common", "fallback banner") end prevSong = prevSong and prevSong or bnpath if prevSong ~= bnpath and prevprevSong == nil then prevprevSong = bnpath end if prevSong ~= bnpath and prevprevSong ~= bnpath then prevSong = bnpath prevprevSong = nil end self:LoadBackground(prevSong) else local bnpath = SONGMAN:GetSongGroupBannerPath(SCREENMAN:GetTopScreen():GetMusicWheel():GetSelectedSection()) if not bnpath or bnpath == "" then bnpath = THEME:GetPathG("Common", "fallback banner") end self:LoadBackground(prevSong) end self:diffusealpha(1) end, ChartPreviewOnMessageCommand = function(self) self:visible(false) end, ChartPreviewOffMessageCommand = function(self) self:visible(true) end } ```

When opening a new file MovieDecoder_FFMpeg was leaking the previous one (And also leaking a buffer and the AVIO context). This should fix that