From 748ca29c488f90d193edd44fbe2bc7ecd15ae21b Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Thu, 1 Jan 2026 17:19:17 +0100 Subject: [PATCH] unregister ert and rtp --- scripts/1-ert.lua | 9 +++++++++ scripts/1-rtp.lua | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/scripts/1-ert.lua b/scripts/1-ert.lua index b008d03..95acc9a 100644 --- a/scripts/1-ert.lua +++ b/scripts/1-ert.lua @@ -34,6 +34,13 @@ local function init_ert() end end +local function unregister_ert() + if _Ert_oda_id ~= nil then + unregister_oda(_Ert_oda_id) + _Ert_oda_id = nil + end +end + function set_rds_ert(ert) if #ert == 0 then set_userdata_offset(USERDATA_ERT_OFFSET, 128, "") @@ -61,6 +68,8 @@ function set_rds_ert(ert) set_userdata_offset(USERDATA_ERT_OFFSET+257, 1, string.char(segments)) _Ert_state = 0 else set_userdata_offset(USERDATA_ERT_OFFSET+258, 1, string.char(1)) end + + if _Ert_oda_id == nil then init_ert() end end function get_rds_ert() diff --git a/scripts/1-rtp.lua b/scripts/1-rtp.lua index a8995b2..105bc95 100644 --- a/scripts/1-rtp.lua +++ b/scripts/1-rtp.lua @@ -79,6 +79,16 @@ function get_rds_rtplus_tags(ertp) return string.byte(get_userdata_offset(ertp and (USERDATA_RTP_OFFSET+8) or (USERDATA_RTP_OFFSET+1), 6), 1, 6) end +local function unregister_rtp(ertp) + if ertp and _Ertp_oda_id ~= nil then + unregister_oda(_Ertp_oda_id) + _Ertp_oda_id = nil + elseif _Rtp_oda_id ~= nil then + unregister_oda(_Rtp_oda_id) + _Rtp_oda_id = nil + end +end + local _old_on_state_rtp = on_state function on_state() if get_rds_rtp_meta(false) then init_rtp() end