Skip to content

Commit

Permalink
Fix feedback loop from volume to channel volumes.
Browse files Browse the repository at this point in the history
  • Loading branch information
saivert committed Jun 11, 2024
1 parent c10aa0d commit 85d2c50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/backend/pwnodeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,18 @@ impl PwNodeObject {
}

pub(crate) fn set_channel_volumes_vec(&self, values: &[f32]) {
*(self.imp().channel_volumes.borrow_mut()) = values.to_owned();

self.update_channel_objects();
self.set_channel_volumes_vec_no_send(values);
if !self.imp().block.get() {
self.send_volume_using_mixerapi(PropertyChanged::ChannelVolumes);
}
}

pub(crate) fn set_channel_volumes_vec_no_send(&self, values: &[f32]) {
*(self.imp().channel_volumes.borrow_mut()) = values.to_owned();

self.update_channel_objects();
}

pub(crate) fn set_channel_volume(&self, index: u32, volume: f32) {
if let Some(value) = self
.imp()
Expand Down
5 changes: 4 additions & 1 deletion src/backend/pwnodeobject/mixerapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ impl PwNodeObject {
*v = max;
}
}
self.set_channel_volumes_vec(&channel_volumes);
if let Some(cv) = self.make_channel_volumes_variant(&self.channel_volumes_vec()) {
variant.insert("channelVolumes", cv);
}
self.set_channel_volumes_vec_no_send(&channel_volumes);
}
PropertyChanged::ChannelVolumes => {
if let Some(cv) = self.make_channel_volumes_variant(&self.channel_volumes_vec()) {
Expand Down

0 comments on commit 85d2c50

Please sign in to comment.