Skip to content

Commit

Permalink
auto_profiles.lua: don't log warnings on exit
Browse files Browse the repository at this point in the history
If a script registers hooks before exiting mpv logs "Sending hook
command failed. Removing hook.". (Also there is no function to
unregister hooks.) Don't register hooks in auto_profiles.lua before it
exits to not log these warnings. Fixes 5dc4047. Fixes #15244.
  • Loading branch information
guidocella committed Nov 2, 2024
1 parent 32bcaf8 commit 72f826c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions player/lua/auto_profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ for _, property in pairs(mp.get_property_native("property-list")) do
property_set[property] = true
end

local first_run = true

local function evaluate(profile)
msg.verbose("Re-evaluating auto profile " .. profile.name)

Expand Down Expand Up @@ -198,10 +200,14 @@ mp.observe_property("profile-list", "native", function (_, profiles_property)
return
end

if first_run then
mp.register_idle(on_idle)
for _, name in ipairs({"on_load", "on_preloaded", "on_before_start_file"}) do
mp.add_hook(name, 50, on_hook)
end

first_run = false
end

on_idle() -- re-evaluate all profiles immediately
end)

mp.register_idle(on_idle)
for _, name in ipairs({"on_load", "on_preloaded", "on_before_start_file"}) do
mp.add_hook(name, 50, on_hook)
end

0 comments on commit 72f826c

Please sign in to comment.