JDK-8202264 : Race condition in AudioClip.loop()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 6,7,8,9,10,11,12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-04-25
  • Updated: 2019-03-19
  • Resolved: 2018-07-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 7 JDK 8
11 b22Fixed 7u211Fixed 8u202Fixed
Related Reports
Relates :  
Description
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.