Relates :
|
AudioClip.loop() may not play sound just after call AudioClip.stop(). A Java thread for DirectAudioDevice$DirectClip isn't created on the folowing cases: 1) loop() -> isOpen(): true, isActive(): true 2) stop() -> isOpen(): true, isActive(): false 3) next loop() -> isOpen(): true, so thread is not created. 4) CLOSE event -> isOpen(): false, isActive(): false, so thread is stopping (thread = null). AbstractLine +- AbstractDataLine +- DirectAudioDevice$DirectDL +- DirectAudioDevice$DirectClip "Direct Clip" thread is created only when AbstractLine.isOpen() is false. And, this thread is stopped at dispatching CLOSE event on Java Sound Event Dispatcher thread, if AbstractDataLine.isActive() is false. AbstractDataLine.isActive() becomes false at DirectClip.stop(), and becomes true at write() on "Direct Clip" thread. There is a race condition that "Direct Clip" thread is stopped unexpectedly.