Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion connect/src/spirc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ enum SpircCommand {
const CONTEXT_FETCH_THRESHOLD: usize = 2;

// delay to update volume after a certain amount of time, instead on each update request
const VOLUME_UPDATE_DELAY: Duration = Duration::from_secs(2);
const VOLUME_UPDATE_DELAY: Duration = Duration::from_millis(500);
Comment thread
photovoltex marked this conversation as resolved.
// to reduce updates to remote, we group some request by waiting for a set amount of time
const UPDATE_STATE_DELAY: Duration = Duration::from_millis(200);

Expand Down
53 changes: 37 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ fn get_setup() -> Setup {
const VERSION: &str = "version";
const VOLUME_CTRL: &str = "volume-ctrl";
const VOLUME_RANGE: &str = "volume-range";
const VOLUME_STEPS: &str = "volume-steps";
const ZEROCONF_PORT: &str = "zeroconf-port";
const ZEROCONF_INTERFACE: &str = "zeroconf-interface";
const ZEROCONF_BACKEND: &str = "zeroconf-backend";
Expand All @@ -291,6 +292,7 @@ fn get_setup() -> Setup {
const DEVICE_SHORT: &str = "d";
const VOLUME_CTRL_SHORT: &str = "E";
const VOLUME_RANGE_SHORT: &str = "e";
const VOLUME_STEPS_SHORT: &str = ""; // no short flag
const DEVICE_TYPE_SHORT: &str = "F";
const FORMAT_SHORT: &str = "f";
const DISABLE_AUDIO_CACHE_SHORT: &str = "G";
Expand Down Expand Up @@ -372,6 +374,9 @@ fn get_setup() -> Setup {
const VOLUME_RANGE_DESC: &str =
"Range of the volume control (dB) from 0.0 to 100.0. Defaults to 60.0.";

const VOLUME_STEPS_DESC: &str =
"Number of incremental steps when responding to volume control. Default: 1024.";

let mut opts = getopts::Options::new();
opts.optflag(
HELP_SHORT,
Expand Down Expand Up @@ -570,6 +575,12 @@ fn get_setup() -> Setup {
VOLUME_RANGE_DESC,
"RANGE",
)
.optopt(
VOLUME_STEPS_SHORT,
VOLUME_STEPS,
VOLUME_STEPS_DESC,
"STEPS",
)
.optopt(
NORMALISATION_METHOD_SHORT,
NORMALISATION_METHOD,
Expand Down Expand Up @@ -1457,7 +1468,8 @@ fn get_setup() -> Setup {
} else {
cache.as_ref().and_then(Cache::volume)
}
});
})
.unwrap_or_default();

let device_type = opt_str(DEVICE_TYPE)
.as_deref()
Expand All @@ -1480,23 +1492,32 @@ fn get_setup() -> Setup {
})
.unwrap_or_default();

let volume_steps = opt_str(VOLUME_STEPS)
.map(|steps| match steps.parse::<u16>() {
Ok(value) => value,
_ => {
invalid_error_msg(
VOLUME_STEPS,
VOLUME_STEPS_SHORT,
&steps,
"a positive whole number <= 65535",
Comment thread
photovoltex marked this conversation as resolved.
"1024",
);

exit(1);
}
})
.unwrap_or_else(|| connect_default_config.volume_steps);

let is_group = opt_present(DEVICE_IS_GROUP);

if let Some(initial_volume) = initial_volume {
ConnectConfig {
name,
device_type,
is_group,
initial_volume,
..Default::default()
}
} else {
ConnectConfig {
name,
device_type,
is_group,
..Default::default()
}
ConnectConfig {
name,
device_type,
is_group,
initial_volume,
volume_steps,
Comment thread
photovoltex marked this conversation as resolved.
..connect_default_config
}
};

Expand Down
Loading