Skip to content

Commit

Permalink
core: Fix reporting rate calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
jpochyla committed Nov 12, 2021
1 parent 1aacefd commit 6e6a2dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions psst-core/src/player/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,9 @@ impl Player {
}
}
const PRELOAD_BEFORE_END_OF_TRACK: Duration = Duration::from_secs(30);
if let Some(&item_to_preload) = self.queue.get_following() {
let time_until_end_of_track =
path.duration.checked_sub(new_position).unwrap_or_default();
if time_until_end_of_track <= PRELOAD_BEFORE_END_OF_TRACK {
let time_until_end_of_track = path.duration.checked_sub(new_position).unwrap_or_default();
if time_until_end_of_track <= PRELOAD_BEFORE_END_OF_TRACK {
if let Some(&item_to_preload) = self.queue.get_following() {
self.preload(item_to_preload);
}
}
Expand Down
2 changes: 1 addition & 1 deletion psst-core/src/player/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl DecoderSource {
let total_samples = cp.n_frames.unwrap() * chan_count as u64;
let time_base = cp.time_base.unwrap();
let precision =
REPORT_PRECISION.as_millis() as u64 / (signal_spec.rate as u64 * chan_count as u64);
(signal_spec.rate as f64 * chan_count as f64 * REPORT_PRECISION.as_secs_f64()) as u64;

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

0 comments on commit 6e6a2dc

Please sign in to comment.