Skip to content

Commit 6e6a2dc

Browse files
committed
core: Fix reporting rate calculation
1 parent 1aacefd commit 6e6a2dc

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

psst-core/src/player/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,9 @@ impl Player {
186186
}
187187
}
188188
const PRELOAD_BEFORE_END_OF_TRACK: Duration = Duration::from_secs(30);
189-
if let Some(&item_to_preload) = self.queue.get_following() {
190-
let time_until_end_of_track =
191-
path.duration.checked_sub(new_position).unwrap_or_default();
192-
if time_until_end_of_track <= PRELOAD_BEFORE_END_OF_TRACK {
189+
let time_until_end_of_track = path.duration.checked_sub(new_position).unwrap_or_default();
190+
if time_until_end_of_track <= PRELOAD_BEFORE_END_OF_TRACK {
191+
if let Some(&item_to_preload) = self.queue.get_following() {
193192
self.preload(item_to_preload);
194193
}
195194
}

psst-core/src/player/worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl DecoderSource {
105105
let total_samples = cp.n_frames.unwrap() * chan_count as u64;
106106
let time_base = cp.time_base.unwrap();
107107
let precision =
108-
REPORT_PRECISION.as_millis() as u64 / (signal_spec.rate as u64 * chan_count as u64);
108+
(signal_spec.rate as f64 * chan_count as f64 * REPORT_PRECISION.as_secs_f64()) as u64;
109109

110110
// Create a ring-buffer for the decoded samples. Worker thread is producing,
111111
// we are consuming in the `AudioSource` impl.

0 commit comments

Comments
 (0)