Skip to content

Commit 70c68f7

Browse files
committed
feat(player): Replace position update interval option with sensible default
1 parent 6ca0583 commit 70c68f7

1 file changed

Lines changed: 4 additions & 25 deletions

File tree

src/main.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ mod mpris_event_handler;
4646
#[cfg(feature = "with-mpris")]
4747
use mpris_event_handler::MprisEventHandler;
4848

49+
// Position update interval set to 400ms (Doherty threshold)
50+
const POSITION_UPDATE_INTERVAL_MS: Duration = Duration::from_millis(400);
51+
4952
fn device_id(name: &str) -> String {
5053
HEXLOWER.encode(&Sha1::digest(name.as_bytes()))
5154
}
@@ -275,7 +278,6 @@ async fn get_setup() -> Setup {
275278
#[cfg(feature = "passthrough-decoder")]
276279
const PASSTHROUGH: &str = "passthrough";
277280
const PASSWORD: &str = "password";
278-
const POSITION_UPDATE_INTERVAL: &str = "position-update-interval";
279281
const PROXY: &str = "proxy";
280282
const QUIET: &str = "quiet";
281283
const SYSTEM_CACHE: &str = "system-cache";
@@ -322,7 +324,6 @@ async fn get_setup() -> Setup {
322324
#[cfg(feature = "passthrough-decoder")]
323325
const PASSTHROUGH_SHORT: &str = "P";
324326
const PASSWORD_SHORT: &str = "p";
325-
const POSITION_UPDATE_INTERVAL_SHORT: &str = ""; // no short flag
326327
const EMIT_SINK_EVENTS_SHORT: &str = "Q";
327328
const QUIET_SHORT: &str = "q";
328329
const INITIAL_VOLUME_SHORT: &str = "R";
@@ -634,12 +635,6 @@ async fn get_setup() -> Setup {
634635
"Knee width (dB) of the dynamic limiter from 0.0 to 10.0. Defaults to 5.0.",
635636
"KNEE",
636637
)
637-
.optopt(
638-
POSITION_UPDATE_INTERVAL_SHORT,
639-
POSITION_UPDATE_INTERVAL,
640-
"Maximum interval in ms for player to send a position event. Defaults to no forced position update.",
641-
"POSITION_UPDATE",
642-
)
643638
.optopt(
644639
ZEROCONF_PORT_SHORT,
645640
ZEROCONF_PORT,
@@ -1826,22 +1821,6 @@ async fn get_setup() -> Setup {
18261821
},
18271822
};
18281823

1829-
let position_update_interval = opt_str(POSITION_UPDATE_INTERVAL).as_deref().map(
1830-
|position_update| match position_update.parse::<u64>() {
1831-
Ok(value) => Duration::from_millis(value),
1832-
_ => {
1833-
invalid_error_msg(
1834-
POSITION_UPDATE_INTERVAL,
1835-
POSITION_UPDATE_INTERVAL_SHORT,
1836-
position_update,
1837-
"Integer value in ms",
1838-
"None",
1839-
);
1840-
exit(1);
1841-
}
1842-
},
1843-
);
1844-
18451824
#[cfg(feature = "passthrough-decoder")]
18461825
let passthrough = opt_present(PASSTHROUGH);
18471826
#[cfg(not(feature = "passthrough-decoder"))]
@@ -1860,7 +1839,7 @@ async fn get_setup() -> Setup {
18601839
normalisation_release_cf,
18611840
normalisation_knee_db,
18621841
ditherer,
1863-
position_update_interval: None,
1842+
position_update_interval: Some(POSITION_UPDATE_INTERVAL_MS),
18641843
local_file_directories,
18651844
}
18661845
};

0 commit comments

Comments
 (0)