Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.

Commit a5b01e3

Browse files
committed
Stop playing when finished.
1 parent 344beb8 commit a5b01e3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

neoplay/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ fn real_main() -> Result<(), neotron_sdk::Error> {
7070
}
7171
let _ = dsp.write(&sample_buffer);
7272
let mut in_buf = [0u8; 1];
73-
if stdin.read(&mut in_buf).is_ok() && in_buf[0] == b'q' {
73+
if player.is_finished() {
74+
break;
75+
}
76+
if stdin.read(&mut in_buf).is_ok() && in_buf[0].to_ascii_lowercase() == b'q' {
7477
break;
7578
}
7679
}

neoplay/src/player.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ impl<'a> Player<'a> {
6363
})
6464
}
6565

66+
/// Are we finished playing?
67+
pub fn is_finished(&self) -> bool {
68+
self.finished
69+
}
70+
6671
/// Return a stereo sample pair
6772
pub fn next_sample<T>(&mut self, out: &mut T) -> (i16, i16)
6873
where

0 commit comments

Comments
 (0)