Skip to content

Commit

Permalink
Fix playback for audio only. (#34)
Browse files Browse the repository at this point in the history
Audio only playback would wait for the new play barrier to hit the wait
if a MIDI device was configured. This has been fixed.
  • Loading branch information
mdwn authored May 14, 2024
1 parent 88bd74b commit 8b93231
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,15 @@ impl Player {
) {
let song = song.clone();
let cancel_handle = cancel_handle.clone();
let barrier = Arc::new(match midi_device {
Some(_) => Barrier::new(2),
None => Barrier::new(1),
});

// Set up the play barrier, which will synchronize the two calls to play.
let barrier = Arc::new(Barrier::new(
if midi_device.is_some() && song.midi_file.is_some() {
2
} else {
1
},
));

let audio_join_handle = {
let device = device.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/songs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Song {
/// The MIDI event to play when the song is selected in a playlist.
pub midi_event: Option<LiveEvent<'static>>,
/// The MIDI file to play along with the audio tracks.
midi_file: Option<PathBuf>,
pub midi_file: Option<PathBuf>,
/// The number of channels required to play this song.
pub num_channels: u16,
/// The sample rate of this song.
Expand Down

0 comments on commit 8b93231

Please sign in to comment.