Sound Issues under Linux & OpenJDK?

The following code does not work under Linux when using the OpenJDK JRE…it will play one sound effect, but then essentially “hangs” the thread, and no more sound effects can be played.

I am struggling to resolve this problem; essentially, it works on all other JRE’s for Mac and Windows, but dies under OpenJDK…

The LineEvent STOP gets fired and I call my stop() method to ready the Sound for playing again. It either dies within setFramePosition() or setMicrosecondPosition() from what I can discern:


public void update(LineEvent e) {							
	if (e.getType() == LineEvent.Type.STOP) {
		stop();
		debug("Stopping Clip "+sfxURL.toString());
	}			
}

public void stop() {

	debug("stop() call for "+sfxURL.toString());

	sfxClip.stop();
		
	sfxClip.setFramePosition(0);
	sfxClip.setMicrosecondPosition(0);
		
	synchronized(sfxClip) {
		sfxClip.notifyAll();  // awaken anyone waiting for this Clip
	}


}


Anyone had this problem before, or any ideas on a way around…?

Thanks!

Pete (Red27).

The OpenJDK sound library sucks, it is buggy as hell and has problems doing low-latency audio. If you are distributing a jre the sun/oracle one works much better. Also Clips are pretty unreliable, especially when you have lots of them as they each grab a mixer line. If you want the most reliable method for doing sound in Java use a single SourceDataLine and do your own software mixing.