Skip to content

Commit 8e15bef

Browse files
committed
feat(player): Add position update option
1 parent 90cd456 commit 8e15bef

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/main.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ async fn get_setup() -> Setup {
275275
#[cfg(feature = "passthrough-decoder")]
276276
const PASSTHROUGH: &str = "passthrough";
277277
const PASSWORD: &str = "password";
278+
const POSITION_UPDATE: &str = "position-update";
278279
const PROXY: &str = "proxy";
279280
const QUIET: &str = "quiet";
280281
const SYSTEM_CACHE: &str = "system-cache";
@@ -320,6 +321,7 @@ async fn get_setup() -> Setup {
320321
#[cfg(feature = "passthrough-decoder")]
321322
const PASSTHROUGH_SHORT: &str = "P";
322323
const PASSWORD_SHORT: &str = "p";
324+
const POSITION_UPDATE_SHORT: &str = ""; // no short flag
323325
const EMIT_SINK_EVENTS_SHORT: &str = "Q";
324326
const QUIET_SHORT: &str = "q";
325327
const INITIAL_VOLUME_SHORT: &str = "R";
@@ -630,6 +632,12 @@ async fn get_setup() -> Setup {
630632
"Knee width (dB) of the dynamic limiter from 0.0 to 10.0. Defaults to 5.0.",
631633
"KNEE",
632634
)
635+
.optopt(
636+
POSITION_UPDATE_SHORT,
637+
POSITION_UPDATE,
638+
"Update position interval in ms",
639+
"POSITION_UPDATE",
640+
)
633641
.optopt(
634642
ZEROCONF_PORT_SHORT,
635643
ZEROCONF_PORT,
@@ -1805,6 +1813,22 @@ async fn get_setup() -> Setup {
18051813
},
18061814
};
18071815

1816+
let position_update_interval = opt_str(POSITION_UPDATE).as_deref().map(|position_update| {
1817+
match position_update.parse::<u64>() {
1818+
Ok(value) => Duration::from_millis(value),
1819+
_ => {
1820+
invalid_error_msg(
1821+
POSITION_UPDATE,
1822+
POSITION_UPDATE_SHORT,
1823+
position_update,
1824+
"Integer value in ms",
1825+
"None",
1826+
);
1827+
exit(1);
1828+
}
1829+
}
1830+
});
1831+
18081832
#[cfg(feature = "passthrough-decoder")]
18091833
let passthrough = opt_present(PASSTHROUGH);
18101834
#[cfg(not(feature = "passthrough-decoder"))]
@@ -1823,7 +1847,7 @@ async fn get_setup() -> Setup {
18231847
normalisation_release_cf,
18241848
normalisation_knee_db,
18251849
ditherer,
1826-
position_update_interval: None,
1850+
position_update_interval,
18271851
}
18281852
};
18291853

0 commit comments

Comments
 (0)