osc.lua: update track state only when track-list changes

There is no need to retrieve track-list on every osc_init().

Also remove the outdated comment.
This commit is contained in:
Guido Cella authored and sfan5 committed 2026-03-12 15:58:21 +01:00
1 parent 11440741cb
commit 6da164452a
1 file changed
+5 -12
+5 -12
View File
@@ -664,22 +664,18 @@ local function render_wipe(osd)
osd:remove()
end
--
-- Tracklist Management
--
-- updates the OSC internal playlists, should be run each time the track-layout changes
local function update_tracklist()
local function update_tracklist(_, track_list)
audio_track_count, sub_track_count = 0, 0
for _, track in pairs(mp.get_property_native("track-list")) do
for _, track in pairs(track_list) do
if track.type == "audio" then
audio_track_count = audio_track_count + 1
elseif track.type == "sub" then
sub_track_count = sub_track_count + 1
end
end
request_init()
end
-- WindowControl helpers
@@ -2045,9 +2041,6 @@ local function osc_init()
ne.content = icons.chapter_next
bind_mouse_buttons("chapter_next")
--
update_tracklist()
--audio_track
ne = new_element("audio_track", "button")
@@ -2780,7 +2773,7 @@ end
mp.register_event("shutdown", shutdown)
mp.register_event("start-file", request_init)
mp.observe_property("track-list", "native", request_init)
mp.observe_property("track-list", "native", update_tracklist)
mp.observe_property("playlist-count", "native", request_init)
mp.observe_property("playlist-pos", "native", request_init)
mp.observe_property("chapter-list", "native", function(_, list)