mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-09 07:28:41 +02:00
autoswitch-bluetooth-profile: Always destroy the restore timeout source before switching
We always have to destroy the restore timeout source when we want to switch to HSP/HFP profile, even if the device is already set to HSP/HFP or has already an input route. Apart from this, we also want to make sure there is no pending timeout source when we are creating a new one. This should avoid an infinite loop about switching BT profiles when capture nodes are created and destroyed quickly.
This commit is contained in:
parent
f57a46308d
commit
2353a0991b
1 changed files with 14 additions and 9 deletions
|
|
@ -212,9 +212,10 @@ local function switchDeviceToHeadsetProfile (dev_id)
|
|||
return
|
||||
end
|
||||
|
||||
if isSwitchedToHeadsetProfile (device) then
|
||||
Log.info ("Device with id " .. tostring(dev_id).. " is already switched to HSP/HFP")
|
||||
return
|
||||
-- clear restore callback, if any
|
||||
if restore_timeout_source[dev_id] ~= nil then
|
||||
restore_timeout_source[dev_id]:destroy ()
|
||||
restore_timeout_source[dev_id] = nil
|
||||
end
|
||||
|
||||
local cur_profile_name = getCurrentProfile (device)
|
||||
|
|
@ -224,10 +225,9 @@ local function switchDeviceToHeadsetProfile (dev_id)
|
|||
return
|
||||
end
|
||||
|
||||
-- clear restore callback, if any
|
||||
if restore_timeout_source[dev_id] ~= nil then
|
||||
restore_timeout_source[dev_id]:destroy ()
|
||||
restore_timeout_source[dev_id] = nil
|
||||
if isSwitchedToHeadsetProfile (device) then
|
||||
Log.info ("Device with id " .. tostring(dev_id).. " is already switched to HSP/HFP")
|
||||
return
|
||||
end
|
||||
|
||||
local saved_headset_profile = getSavedHeadsetProfile (device)
|
||||
|
|
@ -324,7 +324,13 @@ local function triggerRestoreProfile (dev_id)
|
|||
end
|
||||
end
|
||||
|
||||
restore_timeout_source[dev_id] = nil
|
||||
-- clear restore callback, if any
|
||||
if restore_timeout_source[dev_id] ~= nil then
|
||||
restore_timeout_source[dev_id]:destroy ()
|
||||
restore_timeout_source[dev_id] = nil
|
||||
end
|
||||
|
||||
-- create new restore callback
|
||||
restore_timeout_source[dev_id] = Core.timeout_add (profile_restore_timeout_msec, function ()
|
||||
restore_timeout_source[dev_id] = nil
|
||||
restoreProfile (dev_id)
|
||||
|
|
@ -435,7 +441,6 @@ SimpleEventHook {
|
|||
local p = link.properties
|
||||
for stream in streams_om:iterate () do
|
||||
local in_id = tonumber(p["link.input.node"])
|
||||
local out_id = tonumber(p["link.output.node"])
|
||||
local stream_id = tonumber(stream["bound-id"])
|
||||
if in_id == stream_id then
|
||||
handleStream (stream)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue