/** Does any clean up before closing. */ protected void cleanUp() { // signal to unpause setPaused(false); // close the mixer (stops any running sounds) Mixer mixer = AudioSystem.getMixer(null); if (mixer.isOpen()) { mixer.close(); } }
/** * Close the audio clip. There is a bunch of code here attempting to close the audio stream. Turns * out there is a a bug and the only way to close out the background audio threads is to do a * System.exit(). */ public void close() { if (audioClip == null) return; synchronized (audioClip) { audioClip.removeLineListener(this); audioClip.close(); try { audioStream.close(); } catch (IOException e) { System.out.println(e.getMessage()); } // close the mixer (stops any running sounds) Mixer mixer = AudioSystem.getMixer(null); if (mixer.isOpen()) { mixer.close(); } audioState = AudioState.DEAD; } }