Skip to content

Commit

Permalink
[#314] cassette-player: stop
Browse files Browse the repository at this point in the history
  • Loading branch information
vbmacher committed May 13, 2023
1 parent 92eff9a commit 57cd510
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onBlockFlag(int flag) {

@Override
public void onProgram(String filename, int dataLength, int autoStart, int programLength) {
logProgramDetail(filename,"PROGRAM (start=" + autoStart + ", length=" + programLength + ")");
logProgramDetail(filename, "PROGRAM (start=" + autoStart + ", length=" + programLength + ")");
}

@Override
Expand Down Expand Up @@ -156,6 +156,11 @@ public void onFileEnd() {
try {
barrier.await();
} catch (InterruptedException e) {
// cancel playing
for (int cycles : loaderSchedule.keySet()) {
tep.removeAllScheduledOnce(cycles);
}

Thread.currentThread().interrupt();
} catch (BrokenBarrierException e) {
throw new RuntimeException(e);
Expand All @@ -181,7 +186,7 @@ private void transmitByte(int data, String msg) {
int pulseLength = ((data & mask) == 0) ? DATA_PULSE_ZERO_TSTATES : DATA_PULSE_ONE_TSTATES;
schedulePulse(pulseLength, msg); // 2x according to https://sinclair.wiki.zxnet.co.uk/wiki/Spectrum_tape_interface
schedulePulse(pulseLength, "");
msg="";
msg = "";
mask >>>= 1;
}
}
Expand Down Expand Up @@ -214,8 +219,8 @@ private void playPulses() {
barrier.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (BrokenBarrierException e) {
throw new RuntimeException(e);
} catch (BrokenBarrierException ignored) {

}
});
tep.scheduleOnceMultiple(loaderSchedule);
Expand Down

0 comments on commit 57cd510

Please sign in to comment.