Skip to content

Commit

Permalink
Implement Stream (No Music) functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyCoolSlug committed Aug 29, 2024
1 parent f67f8b7 commit 674ed87
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions daemon/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use goxlr_types::{
Button, ChannelName, DeviceType, DisplayModeComponents, EffectBankPresets, EffectKey,
EncoderName, FaderName, HardTuneSource, InputDevice as BasicInputDevice, MicrophoneParamKey,
Mix, MuteState, OutputDevice as BasicOutputDevice, RobotRange, SampleBank, SampleButtons,
SamplePlaybackMode, VersionNumber, WaterfallDirection,
SamplePlaybackMode, VersionNumber, VodMode, WaterfallDirection,
};
use goxlr_usb::animation::{AnimationMode, WaterFallDir};
use goxlr_usb::buttonstate::{ButtonStates, Buttons};
Expand Down Expand Up @@ -2934,7 +2934,7 @@ impl<'a> Device<'a> {
Ok(())
}

fn apply_transient_routing(
async fn apply_transient_routing(
&self,
input: BasicInputDevice,
router: &mut EnumMap<BasicOutputDevice, bool>,
Expand All @@ -2953,21 +2953,22 @@ impl<'a> Device<'a> {

for fader in FaderName::iter() {
if self.profile.get_fader_assignment(fader) == channel_name {
self.apply_transient_fader_routing(channel_name, fader, router)?;
self.apply_transient_fader_routing(channel_name, fader, router)
.await?;
}
}

// Chat Mic has a Transient routing option related to the Voice Chat channel, we need
// to ensure that if we're handling the mic, we handle it here.
if channel_name == ChannelName::Mic {
self.apply_transient_chat_mic_mute(router)?;
self.apply_transient_cough_routing(router)?;
self.apply_transient_cough_routing(router).await?;
}

Ok(())
}

fn apply_transient_fader_routing(
async fn apply_transient_fader_routing(
&self,
channel_name: ChannelName,
fader: FaderName,
Expand All @@ -2981,9 +2982,10 @@ impl<'a> Device<'a> {
mute_function,
router,
)
.await
}

fn apply_transient_cough_routing(
async fn apply_transient_cough_routing(
&self,
router: &mut EnumMap<BasicOutputDevice, bool>,
) -> Result<()> {
Expand All @@ -2998,6 +3000,7 @@ impl<'a> Device<'a> {
mute_function,
router,
)
.await
}

fn apply_transient_chat_mic_mute(
Expand All @@ -3022,7 +3025,7 @@ impl<'a> Device<'a> {
Ok(())
}

fn apply_transient_channel_routing(
async fn apply_transient_channel_routing(
&self,
channel_name: ChannelName,
muted_to_x: bool,
Expand All @@ -3044,7 +3047,15 @@ impl<'a> Device<'a> {

match mute_function {
MuteFunction::All => {}
MuteFunction::ToStream => router[BasicOutputDevice::BroadcastMix] = false,
MuteFunction::ToStream => {
// Disable routing to the Stream Mix
router[BasicOutputDevice::BroadcastMix] = false;

// If we're a mini, with VOD Mode 'Stream No Music', disable this route to VOD.
if self.is_steam_no_music().await {
router[BasicOutputDevice::Sampler] = false;
}
}
MuteFunction::ToVoiceChat => router[BasicOutputDevice::ChatMic] = false,
MuteFunction::ToPhones => router[BasicOutputDevice::Headphones] = false,
MuteFunction::ToLineOut => router[BasicOutputDevice::LineOut] = false,
Expand All @@ -3071,7 +3082,18 @@ impl<'a> Device<'a> {
}
}

self.apply_transient_routing(input, &mut router)?;
if self.is_steam_no_music().await {
// Ok, so we need to sync the Mix channel to the Sample (VOD) Channel, unless Music
if input == BasicInputDevice::Music {
// Force Music -> Sample to Off
router[BasicOutputDevice::Sampler] = false;
} else {
// Sync the Mix and Sampler (VOD) channels
router[BasicOutputDevice::Sampler] = router[BasicOutputDevice::BroadcastMix];
}
}

self.apply_transient_routing(input, &mut router).await?;
debug!("Applying Routing to {:?}:", input);
debug!("{:?}", router);

Expand Down Expand Up @@ -3808,6 +3830,11 @@ impl<'a> Device<'a> {
DeviceType::Mini => version_newer_or_equal_to(current, support_mini),
}
}

async fn is_steam_no_music(&self) -> bool {
self.hardware.device_type == DeviceType::Mini
&& self.settings.get_device_vod_mode(self.serial()).await == VodMode::StreamNoMusic
}
}

fn tts_bool_to_state(bool: bool) -> String {
Expand Down

0 comments on commit 674ed87

Please sign in to comment.