1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use crate::cli::ChannelVolumes;
use crate::Client;
use anyhow::Result;
use goxlr_ipc::GoXLRCommand;
use goxlr_types::ChannelName;

pub async fn apply_channel_volumes(
    channel_volumes: &ChannelVolumes,
    client: &mut Client,
    serial: &str,
) -> Result<()> {
    if let Some(volume) = channel_volumes.mic_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::Mic, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.line_in_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::LineIn, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.console_volume {
        client
            .command(
                serial,
                GoXLRCommand::SetVolume(ChannelName::Console, volume),
            )
            .await?;
    }
    if let Some(volume) = channel_volumes.system_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::System, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.game_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::Game, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.chat_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::Chat, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.sample_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::Sample, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.music_volume {
        client
            .command(serial, GoXLRCommand::SetVolume(ChannelName::Music, volume))
            .await?;
    }
    if let Some(volume) = channel_volumes.headphones_volume {
        client
            .command(
                serial,
                GoXLRCommand::SetVolume(ChannelName::Headphones, volume),
            )
            .await?;
    }
    if let Some(volume) = channel_volumes.mic_monitor_volume {
        client
            .command(
                serial,
                GoXLRCommand::SetVolume(ChannelName::MicMonitor, volume),
            )
            .await?;
    }
    if let Some(volume) = channel_volumes.line_out_volume {
        client
            .command(
                serial,
                GoXLRCommand::SetVolume(ChannelName::LineOut, volume),
            )
            .await?;
    }
    Ok(())
}