mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-03-01 03:30:04 +00:00
Fixed playback thread handling as well as isRunning detection to fix stuck threads
This commit is contained in:
parent
3d348a2a5e
commit
26ba3083ea
@ -209,6 +209,10 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return super.isRunning() && playbackThread != null && playbackThread.isAlive();
|
||||||
|
}
|
||||||
|
|
||||||
private void doSoundTick() {
|
private void doSoundTick() {
|
||||||
if (isRunning() && !pause) {
|
if (isRunning() && !pause) {
|
||||||
// buildMixerTable();
|
// buildMixerTable();
|
||||||
@ -356,11 +360,11 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
int zeroSamples = 0;
|
int zeroSamples = 0;
|
||||||
setRun(true);
|
setRun(true);
|
||||||
LockSupport.parkNanos(5000);
|
LockSupport.parkNanos(5000);
|
||||||
while (isRunning()) {
|
while (isRunning() && !Thread.interrupted()) {
|
||||||
while (isRunning() && !computer.isRunning()) {
|
while (isRunning() && !computer.isRunning()) {
|
||||||
Thread.currentThread().yield();
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
if (isRunning()) {
|
if (isRunning() && !Thread.interrupted()) {
|
||||||
playSound(leftBuffer, rightBuffer);
|
playSound(leftBuffer, rightBuffer);
|
||||||
int p = 0;
|
int p = 0;
|
||||||
for (int idx = 0; idx < BUFFER_LENGTH; idx++) {
|
for (int idx = 0; idx < BUFFER_LENGTH; idx++) {
|
||||||
@ -425,6 +429,8 @@ public class CardMockingboard extends Card implements Runnable {
|
|||||||
} catch (LineUnavailableException ex) {
|
} catch (LineUnavailableException ex) {
|
||||||
Logger.getLogger(CardMockingboard.class
|
Logger.getLogger(CardMockingboard.class
|
||||||
.getName()).log(Level.SEVERE, null, ex);
|
.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(CardMockingboard.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} finally {
|
} finally {
|
||||||
computer.getMotherboard().cancelSpeedRequest(this);
|
computer.getMotherboard().cancelSpeedRequest(this);
|
||||||
System.out.println("Mockingboard playback stopped");
|
System.out.println("Mockingboard playback stopped");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user