From 6a734b8be7fb4449dff84763b0cb5a2ce508cb71 Mon Sep 17 00:00:00 2001 From: Craig McLure Date: Tue, 6 Aug 2024 08:00:37 +0100 Subject: [PATCH] Correctly load all submix volumes on profile load (Thanks Dadbeard!) --- daemon/src/device.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/daemon/src/device.rs b/daemon/src/device.rs index be975cf3..02d921af 100644 --- a/daemon/src/device.rs +++ b/daemon/src/device.rs @@ -1590,6 +1590,8 @@ impl<'a> Device<'a> { if linked_volume != mix_current_volume { self.profile.set_submix_volume(mix, linked_volume)?; + + debug!("Setting Sub Mix volume for {} to {}", mix, linked_volume); self.goxlr.set_sub_volume(mix, linked_volume)?; } } @@ -3676,7 +3678,7 @@ impl<'a> Device<'a> { if submix_enabled && apply_volumes { for channel in ChannelName::iter() { - self.sync_submix_volume(channel)?; + self.load_submix_volume(channel)?; } } @@ -3692,16 +3694,19 @@ impl<'a> Device<'a> { Ok(()) } - fn sync_submix_volume(&mut self, channel: ChannelName) -> Result<()> { + fn load_submix_volume(&mut self, channel: ChannelName) -> Result<()> { if let Some(mix) = self.profile.get_submix_from_channel(channel) { - if self.profile.is_channel_linked(mix) { - // Get the channels volume.. + let volume = if self.profile.is_channel_linked(mix) { let volume = self.profile.get_channel_volume(channel); - self.update_submix_for(channel, volume)?; + let ratio = self.profile.get_submix_ratio(mix); + + (volume as f64 * ratio) as u8 } else { - let sub_volume = self.profile.get_submix_volume(mix); - self.goxlr.set_sub_volume(mix, sub_volume)?; - } + self.profile.get_submix_volume(mix) + }; + + debug!("Setting Sub Mix volume for {} to {}", mix, volume); + self.goxlr.set_sub_volume(mix, volume)?; } Ok(()) } @@ -3726,6 +3731,8 @@ impl<'a> Device<'a> { // Apply the submix volume.. self.profile.set_submix_volume(mix, volume)?; + + debug!("Setting Sub Mix volume for {} to {}", mix, volume); self.goxlr.set_sub_volume(mix, volume)?; } Ok(())