Skip to content

Commit

Permalink
Delay Volume Updates (#19)
Browse files Browse the repository at this point in the history
* Add check for comparing old volume with new volume

* Add Copyright notice
  • Loading branch information
parzival-space authored Sep 8, 2024
1 parent de86bc4 commit bdfafa4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions FaderSyncPlugin/FaderSyncPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<!-- This Version will be used in CI -->
<Version>1.2.1</Version>
<Copyright>© Malte Linke</Copyright>
</PropertyGroup>

<PropertyGroup>
Expand Down
13 changes: 10 additions & 3 deletions FaderSyncPlugin/OBS/GoXlrChannelSyncFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,16 @@ private static unsafe void Tick(void* data, float seconds)
break;
}

// Update OBS Volume
Obs.obs_source_set_volume(target, obsVolume);
Obs.obs_source_set_muted(target, isMuted ? (byte)1 : (byte)0);
// only update channel if values changed
var oldMuteState = (byte)1 == Obs.obs_source_muted(target);
var oldVolume = Obs.obs_source_get_volume(target);
if (Math.Abs(oldVolume - obsVolume) > 0.0001 || isMuted != oldMuteState)
{
// Update OBS Volume
Obs.obs_source_set_volume(target, obsVolume);
Obs.obs_source_set_muted(target, isMuted ? (byte)1 : (byte)0);
Log.Info($"Updated volume for channel '{channelName}' to {obsVolume} (muted: {isMuted})");
}
}

[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
Expand Down
4 changes: 4 additions & 0 deletions UtilityClient/UtilityClient.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Copyright>© Malte Linke</Copyright>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down

0 comments on commit bdfafa4

Please sign in to comment.