Skip to content

Commit

Permalink
test alive
Browse files Browse the repository at this point in the history
  • Loading branch information
jimomulloy committed Dec 14, 2023
1 parent ff408f7 commit b3ddbb8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
14 changes: 14 additions & 0 deletions instrument-core/src/main/java/jomu/instrument/Instrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public static void setInstance(final Instrument injectedInstrument) {
@Inject
Workspace workspace;

private boolean isAlive = false;

/**
* Gets the console.
*
Expand Down Expand Up @@ -178,6 +180,7 @@ public void start() {
this.workspace.start();
this.console.start();
this.coordinator.start();
this.setAlive(true);
LOG.severe(">>Started INSTRUMENT");
} catch (final Exception ex) {
LOG.log(Level.SEVERE, ">>Start INSTRUMENT exception: " + ex.getMessage(), ex);
Expand All @@ -196,6 +199,17 @@ public void stop() {
this.workspace.stop();
this.console.stop();
this.coordinator.stop();
this.setAlive(false);
}

public boolean isAlive() {
return isAlive;

}

public void setAlive(boolean isAlive) {
this.isAlive = isAlive;

}

}
24 changes: 15 additions & 9 deletions instrument-core/src/main/java/jomu/instrument/actuation/Voice.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jomu.instrument.Instrument;
import jomu.instrument.InstrumentException;
import jomu.instrument.Organ;
import jomu.instrument.audio.AudioSynthesizer;
Expand Down Expand Up @@ -80,6 +81,9 @@ public SendMessage(final ToneTimeFrame toneTimeFrame, final String streamId, fin
@Inject
ParameterManager parameterManager;

@Inject
Instrument instrument;

@Inject
Console console;

Expand Down Expand Up @@ -171,15 +175,17 @@ public void close(final String streamId) {
this.deadStreams.remove(streamId);
this.midiSynthesizer.clear(streamId);
this.midiSynthesizer.reset();
this.console.getVisor().setPlayerState(true);
this.LOG.severe(">>Voice CLOSED, midi running: " + this.midiSynthesizer.isSynthesizerRunning() + ", "
+ ", Frame Cache Size: " + this.workspace.getAtlas()
.getFrameCache()
.getSize());
if (this.controller.isCountDownLatch()) {
LOG.severe(">>Voice CLOSE JOB");
this.controller.getCountDownLatch()
.countDown();
if (this.instrument.isAlive()) {
this.console.getVisor().setPlayerState(true);
this.LOG.severe(">>Voice CLOSED, midi running: " + this.midiSynthesizer.isSynthesizerRunning() + ", "
+ ", Frame Cache Size: " + this.workspace.getAtlas()
.getFrameCache()
.getSize());
if (this.controller.isCountDownLatch()) {
LOG.severe(">>Voice CLOSE JOB");
this.controller.getCountDownLatch()
.countDown();
}
}
}
}
Expand Down

0 comments on commit b3ddbb8

Please sign in to comment.