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)
|
-- 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 get-volume` and this volume are related, in that the volume reported by
|
||||||
-- wpctl is the cube-root of this one.
|
-- wpctl is the cube-root of this one.
|
||||||
volume = {}, -- object-id (number) -> volume (number)
|
volume = nil, -- number
|
||||||
mute = {}, -- object-id (number) -> mute (bool)
|
mute = nil, -- bool
|
||||||
last_audio_device_id = nil, -- TODO: might not actually be necessary
|
|
||||||
|
|
||||||
-- parser state:
|
-- parser state:
|
||||||
changed_id = nil,
|
|
||||||
in_device = false,
|
in_device = false,
|
||||||
in_direction = false,
|
in_direction = false,
|
||||||
in_output = false,
|
in_output = false,
|
||||||
|
@ -107,18 +105,12 @@ function pwmon_parser_new()
|
||||||
msg.trace("pw-mon:", line)
|
msg.trace("pw-mon:", line)
|
||||||
line = ltrim(line)
|
line = ltrim(line)
|
||||||
if startswith(line, "changed:") or startswith(line, "added:") or startswith(line, "removed:") then
|
if startswith(line, "changed:") or startswith(line, "added:") or startswith(line, "removed:") then
|
||||||
self.changed_id = nil
|
|
||||||
self.in_device = false
|
self.in_device = false
|
||||||
self.in_direction = false
|
self.in_direction = false
|
||||||
self.in_output = false
|
self.in_output = false
|
||||||
self.in_vol = false
|
self.in_vol = false
|
||||||
self.in_mute = false
|
self.in_mute = false
|
||||||
self.in_properties = 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
|
elseif startswith(line, "type: ") then
|
||||||
self.in_device = startswith(line, "type: PipeWire:Interface:Device")
|
self.in_device = startswith(line, "type: PipeWire:Interface:Device")
|
||||||
msg.trace("parsed type:", line, self.in_device)
|
msg.trace("parsed type:", line, self.in_device)
|
||||||
|
@ -142,29 +134,22 @@ function pwmon_parser_new()
|
||||||
self:feed_mute(value)
|
self:feed_mute(value)
|
||||||
elseif startswith(line, "properties:") and self.in_device then
|
elseif startswith(line, "properties:") and self.in_device then
|
||||||
self.in_properties = true
|
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
|
||||||
end,
|
end,
|
||||||
|
|
||||||
feed_volume = function(self, vol)
|
feed_volume = function(self, vol)
|
||||||
msg.debug("volume:", self.changed_id, vol)
|
msg.debug("volume:", vol)
|
||||||
self.volume[self.changed_id] = vol
|
self.volume = vol
|
||||||
end,
|
end,
|
||||||
feed_mute = function(self, mute)
|
feed_mute = function(self, mute)
|
||||||
msg.debug("mute:", self.changed_id, mute)
|
msg.debug("mute:", mute)
|
||||||
self.mute[self.changed_id] = mute
|
self.mute = mute
|
||||||
end,
|
end,
|
||||||
get_effective_volume = function(self, id)
|
get_effective_volume = function(self)
|
||||||
if id == nil then
|
if self.mute then
|
||||||
id = self.last_audio_device_id
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.mute[id] then
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return self.volume[id]
|
return self.volume
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user