mpv: sane-sysvol: remove the unused id tracking
This commit is contained in:
parent
c37e94493f
commit
8181a0664d
|
@ -91,12 +91,10 @@ function pwmon_parser_new()
|
|||
-- volume: pipewire-native volume. usually 0.0 - 1.0, but can go higher (e.g. 3.25)
|
||||
-- `wpctl get-volume` and this volume are related, in that the volume reported by
|
||||
-- wpctl is the cube-root of this one.
|
||||
volume = {}, -- object-id (number) -> volume (number)
|
||||
mute = {}, -- object-id (number) -> mute (bool)
|
||||
last_audio_device_id = nil, -- TODO: might not actually be necessary
|
||||
volume = nil, -- number
|
||||
mute = nil, -- bool
|
||||
|
||||
-- parser state:
|
||||
changed_id = nil,
|
||||
in_device = false,
|
||||
in_direction = false,
|
||||
in_output = false,
|
||||
|
@ -107,18 +105,12 @@ function pwmon_parser_new()
|
|||
msg.trace("pw-mon:", line)
|
||||
line = ltrim(line)
|
||||
if startswith(line, "changed:") or startswith(line, "added:") or startswith(line, "removed:") then
|
||||
self.changed_id = nil
|
||||
self.in_device = false
|
||||
self.in_direction = false
|
||||
self.in_output = false
|
||||
self.in_vol = false
|
||||
self.in_mute = false
|
||||
self.in_properties = false
|
||||
elseif startswith(line, "id: ") then
|
||||
if self.changed_id == nil then
|
||||
self.changed_id = tonumber(strip_prefix(line, "id: "))
|
||||
msg.debug("changed_id:", self.changed_id)
|
||||
end
|
||||
elseif startswith(line, "type: ") then
|
||||
self.in_device = startswith(line, "type: PipeWire:Interface:Device")
|
||||
msg.trace("parsed type:", line, self.in_device)
|
||||
|
@ -142,29 +134,22 @@ function pwmon_parser_new()
|
|||
self:feed_mute(value)
|
||||
elseif startswith(line, "properties:") and self.in_device then
|
||||
self.in_properties = true
|
||||
elseif line == 'media.class = "Audio/Device"' and self.in_device and self.in_properties then
|
||||
self.last_audio_device_id = self.changed_id
|
||||
msg.debug("last_audio_device_id:", self.changed_id)
|
||||
end
|
||||
end,
|
||||
|
||||
feed_volume = function(self, vol)
|
||||
msg.debug("volume:", self.changed_id, vol)
|
||||
self.volume[self.changed_id] = vol
|
||||
msg.debug("volume:", vol)
|
||||
self.volume = vol
|
||||
end,
|
||||
feed_mute = function(self, mute)
|
||||
msg.debug("mute:", self.changed_id, mute)
|
||||
self.mute[self.changed_id] = mute
|
||||
msg.debug("mute:", mute)
|
||||
self.mute = mute
|
||||
end,
|
||||
get_effective_volume = function(self, id)
|
||||
if id == nil then
|
||||
id = self.last_audio_device_id
|
||||
end
|
||||
|
||||
if self.mute[id] then
|
||||
get_effective_volume = function(self)
|
||||
if self.mute then
|
||||
return 0
|
||||
else
|
||||
return self.volume[id]
|
||||
return self.volume
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user