mirror of
https://gitlab.freedesktop.org/pipewire/helvum.git
synced 2026-05-05 06:38:01 +02:00
wip: pull mute prop change from POD
This commit is contained in:
parent
60fc61a83c
commit
0a790469a8
4 changed files with 24 additions and 14 deletions
|
|
@ -71,8 +71,9 @@ mod imp {
|
|||
id,
|
||||
volume,
|
||||
channel_volumes,
|
||||
mute,
|
||||
} => {
|
||||
self.node_props_changed(id, volume, &channel_volumes);
|
||||
self.node_props_changed(id, volume, &channel_volumes, mute);
|
||||
}
|
||||
PipewireMessage::PortAdded {
|
||||
id,
|
||||
|
|
@ -353,7 +354,7 @@ mod imp {
|
|||
self.obj().graph().clear();
|
||||
}
|
||||
|
||||
fn node_props_changed(&self, id: u32, volume: Option<f32>, channel_volumes: &[f32]) {
|
||||
fn node_props_changed(&self, id: u32, volume: Option<f32>, channel_volumes: &[f32], mute: Option<bool>) {
|
||||
let items = self.items.borrow();
|
||||
|
||||
let Some(node) = items.get(&id) else {
|
||||
|
|
@ -372,6 +373,9 @@ mod imp {
|
|||
if let Some(vol) = vol {
|
||||
node.set_node_volume(vol as f64);
|
||||
}
|
||||
if let Some(mute) = mute {
|
||||
node.set_mute(mute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ pub enum PipewireMessage {
|
|||
id: u32,
|
||||
volume: Option<f32>,
|
||||
channel_volumes: Vec<f32>,
|
||||
mute: Option<bool>,
|
||||
},
|
||||
PortAdded {
|
||||
id: u32,
|
||||
|
|
|
|||
|
|
@ -42,14 +42,9 @@ use pipewire::{
|
|||
param::{ParamInfoFlags, ParamType},
|
||||
pod::parser::Parser,
|
||||
sys::{
|
||||
spa_pod, spa_pod_array, spa_pod_array_body, spa_pod_find_prop, spa_pod_frame,
|
||||
spa_pod_get_float, spa_pod_is_array, spa_pod_is_inside, spa_pod_object,
|
||||
spa_pod_parser_pod, spa_pod_prop, spa_pod_prop_first, spa_pod_prop_is_inside,
|
||||
spa_pod_prop_next, spa_ptrinside, SPA_PROP_channelVolumes, SPA_PROP_volume,
|
||||
SPA_TYPE_OBJECT_Props,
|
||||
spa_pod, spa_pod_array, spa_pod_array_body, spa_pod_find_prop, spa_pod_frame, spa_pod_get_float, spa_pod_is_array, spa_pod_is_inside, spa_pod_object, spa_pod_parser_pod, spa_pod_prop, spa_pod_prop_first, spa_pod_prop_is_inside, spa_pod_prop_next, spa_ptrinside, SPA_PROP_channelVolumes, SPA_PROP_mute, SPA_PROP_volume, SPA_TYPE_OBJECT_Props
|
||||
},
|
||||
utils::result::SpaResult,
|
||||
utils::{dict::DictRef, SpaTypes},
|
||||
utils::{dict::DictRef, result::SpaResult, SpaTypes},
|
||||
},
|
||||
types::ObjectType,
|
||||
};
|
||||
|
|
@ -367,6 +362,7 @@ fn handle_node_params(
|
|||
SpaTypes::Object => {
|
||||
let mut volume = None;
|
||||
let mut channel_volumes = vec![];
|
||||
let mut mute = None;
|
||||
// FIXME: use libspa methods as soon as they are available
|
||||
unsafe {
|
||||
let pod = pod.as_raw_ptr();
|
||||
|
|
@ -404,6 +400,10 @@ fn handle_node_params(
|
|||
}
|
||||
iter = iter.byte_offset((*body).child.size as isize);
|
||||
}
|
||||
} else if (*prop).key == SPA_PROP_mute && inner_pod.is_bool() {
|
||||
let m = inner_pod.get_bool().unwrap();
|
||||
debug!("Found mute Prop: {m}");
|
||||
mute = Some(m);
|
||||
}
|
||||
prop = spa_pod_prop_next(prop);
|
||||
}
|
||||
|
|
@ -413,6 +413,7 @@ fn handle_node_params(
|
|||
id,
|
||||
volume,
|
||||
channel_volumes,
|
||||
mute,
|
||||
})
|
||||
.expect("Failed to send message");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,11 +202,6 @@ mod imp {
|
|||
if let Err(e) = cmd {
|
||||
log::error!("Failed to change volume: {e}");
|
||||
}
|
||||
button.set_icon_name(if is_muted {
|
||||
"audio-volume-high"
|
||||
} else {
|
||||
"audio-volume-muted"
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -239,4 +234,13 @@ impl Node {
|
|||
log::warn!("Tried to remove non-existant port widget from node");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_mute(&self, is_muted: bool) {
|
||||
self.imp().node_mute_button.set_icon_name(if is_muted {
|
||||
"audio-volume-muted"
|
||||
} else {
|
||||
"audio-volume-high"
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue