Skip to content

Commit

Permalink
core: Fix bug introduced in d136d3b
Browse files Browse the repository at this point in the history
  • Loading branch information
jpochyla committed Jan 4, 2021
1 parent 395fc31 commit da88499
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion psst-core/src/audio_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ impl PlayerAudioSource {
self.samples += 1;
} else {
self.samples = 0;
self.current.take();
}
sample
} else {
Expand Down Expand Up @@ -670,12 +669,18 @@ impl Iterator for PlayerAudioSource {
fn next(&mut self) -> Option<Self::Item> {
let sample = self.next_sample();
if sample.is_some() {
// Report audio progress.
if self.samples % PROGRESS_PRECISION_SAMPLES == 0 {
self.report_audio_position()
}
} else {
// We're at the end of track. If we still have the source, drop it and report.
// Player will pause the audio output and we will stop getting polled
// eventually.
if self.current.take().is_some() {
self.report_audio_end();
}
}
sample
}
}
Expand Down

0 comments on commit da88499

Please sign in to comment.