-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.4.0_01
-
None
-
x86
-
linux_redhat_7.1
SYMPTOM
--------
When playing a number of Clips in a row, the system will eventually hang. Attached is some java code that shows the hang on our systems. The code is fairly straight forward:
for ( ) {
Start playing a clip
wait for notify
}
Clip LineListener() {
on STOP sleep a bit then close the clip
on CLOSE notify
}
CAUSE
------
Sometimes we will fail to receive the STOP event. Since the STOP event handler is responsible for closing the clip, we never get a chance to close it, and will end up waiting forever for the clip to close.
The longer I make the delay before the clip is closed, the less frequently this happens.
I've attached the java code, and the thread stack trace after a hang.
EXAMPLE
-------
import javax.sound.sampled.*;
public class AudioHangDemo {
private Clip clip;
private int count = 1;
public void playClip() throws Exception {
// test.wav is any short (1 second) wave file
AudioInputStream audioInputStream =
AudioSystem.getAudioInputStream(new java.io.File("test.wav"));
DataLine.Info info =
new DataLine.Info(Clip.class, audioInputStream.getFormat());
clip = (Clip) AudioSystem.getLine(info);
clip.addLineListener(new LineListener() {
public void update(LineEvent e) {
if (e.getType() == LineEvent.Type.STOP) {
System.out.println("STOP");
try {
Thread.sleep(50);
} catch (InterruptedException ie) {}
clip.close();
}
else if (e.getType() == LineEvent.Type.CLOSE) {
System.out.println("CLOSE");
synchronized(AudioHangDemo.this) {
AudioHangDemo.this.notify();
}
}
else if (e.getType() == LineEvent.Type.START) {
System.out.println("START");
}
}
});
clip.open(audioInputStream);
System.out.println(" ---------- start " + count + " --------");
clip.start();
System.out.println("waiting ... ");
synchronized(this) {
wait();
}
System.out.println("... done");
count++;
}
public static void main(String[] args) throws Exception {
AudioHangDemo ahd = new AudioHangDemo();
for (int i = 0; i < 1000; i++) {
ahd.playClip();
}
System.exit(0);
}
}
STACK DUMP
---------------
Full thread dump Java HotSpot(TM) Client VM (1.4.0-rc-b91 mixed mode):
"Headspace mixer frame proc thread" daemon prio=1 tid=0x0x813c7b8 nid=0x1214 waiting on monitor [4c796000..4c79686c]
at java.lang.Thread.sleep(Native Method)
at com.sun.media.sound.MixerThread.runNative(Native Method)
at com.sun.media.sound.MixerThread.run(MixerThread.java:314)
"Java Sound event dispatcher" prio=1 tid=0x0x813a210 nid=0x1213 waiting on monitor [4c6ae000..4c6ae86c]
at java.lang.Object.wait(Native Method)
- waiting on <0x445f9d38> (a com.sun.media.sound.EventDispatcher)
at java.lang.Object.wait(Object.java:426)
at com.sun.media.sound.EventDispatcher.dispatchEvents(EventDispatcher.java:294)
- locked <0x445f9d38> (a com.sun.media.sound.EventDispatcher)
at com.sun.media.sound.EventDispatcher.run(EventDispatcher.java:345)
at java.lang.Thread.run(Thread.java:536)
"Signal Dispatcher" daemon prio=1 tid=0x0x807bc50 nid=0x1211 waiting on monitor [0..0]
"Finalizer" daemon prio=1 tid=0x0x8074578 nid=0x120e waiting on monitor [4c2e2000..4c2e286c]
at java.lang.Object.wait(Native Method)
- waiting on <0x445ea290> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
- locked <0x445ea290> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=1 tid=0x0x8073930 nid=0x120d waiting on monitor [4c261000..4c26186c]
at java.lang.Object.wait(Native Method)
- waiting on <0x445ea2f8> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:426)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:113)
- locked <0x445ea2f8> (a java.lang.ref.Reference$Lock)
"main" prio=1 tid=0x0x80515d8 nid=0x120a waiting on monitor [bfffd000..bfffd6fc]
at java.lang.Object.wait(Native Method)
- waiting on <0x445ea310> (a AudioHangDemo)
at java.lang.Object.wait(Object.java:426)
at AudioHangDemo.playClip(AudioHangDemo.java:40)
- locked <0x445ea310> (a AudioHangDemo)
at AudioHangDemo.main(AudioHangDemo.java:50)
"VM Thread" prio=1 tid=0x0x80707b0 nid=0x120c runnable
"VM Periodic Task Thread" prio=1 tid=0x0x807a778 nid=0x120f waiting on monitor
"Suspend Checker Thread" prio=1 tid=0x0x807b1d8 nid=0x1210 runnable
CONFIGURATION
-------------
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)
I am running on RedHat 7.2, no ALSA, emu10k sound.
--------
When playing a number of Clips in a row, the system will eventually hang. Attached is some java code that shows the hang on our systems. The code is fairly straight forward:
for ( ) {
Start playing a clip
wait for notify
}
Clip LineListener() {
on STOP sleep a bit then close the clip
on CLOSE notify
}
CAUSE
------
Sometimes we will fail to receive the STOP event. Since the STOP event handler is responsible for closing the clip, we never get a chance to close it, and will end up waiting forever for the clip to close.
The longer I make the delay before the clip is closed, the less frequently this happens.
I've attached the java code, and the thread stack trace after a hang.
EXAMPLE
-------
import javax.sound.sampled.*;
public class AudioHangDemo {
private Clip clip;
private int count = 1;
public void playClip() throws Exception {
// test.wav is any short (1 second) wave file
AudioInputStream audioInputStream =
AudioSystem.getAudioInputStream(new java.io.File("test.wav"));
DataLine.Info info =
new DataLine.Info(Clip.class, audioInputStream.getFormat());
clip = (Clip) AudioSystem.getLine(info);
clip.addLineListener(new LineListener() {
public void update(LineEvent e) {
if (e.getType() == LineEvent.Type.STOP) {
System.out.println("STOP");
try {
Thread.sleep(50);
} catch (InterruptedException ie) {}
clip.close();
}
else if (e.getType() == LineEvent.Type.CLOSE) {
System.out.println("CLOSE");
synchronized(AudioHangDemo.this) {
AudioHangDemo.this.notify();
}
}
else if (e.getType() == LineEvent.Type.START) {
System.out.println("START");
}
}
});
clip.open(audioInputStream);
System.out.println(" ---------- start " + count + " --------");
clip.start();
System.out.println("waiting ... ");
synchronized(this) {
wait();
}
System.out.println("... done");
count++;
}
public static void main(String[] args) throws Exception {
AudioHangDemo ahd = new AudioHangDemo();
for (int i = 0; i < 1000; i++) {
ahd.playClip();
}
System.exit(0);
}
}
STACK DUMP
---------------
Full thread dump Java HotSpot(TM) Client VM (1.4.0-rc-b91 mixed mode):
"Headspace mixer frame proc thread" daemon prio=1 tid=0x0x813c7b8 nid=0x1214 waiting on monitor [4c796000..4c79686c]
at java.lang.Thread.sleep(Native Method)
at com.sun.media.sound.MixerThread.runNative(Native Method)
at com.sun.media.sound.MixerThread.run(MixerThread.java:314)
"Java Sound event dispatcher" prio=1 tid=0x0x813a210 nid=0x1213 waiting on monitor [4c6ae000..4c6ae86c]
at java.lang.Object.wait(Native Method)
- waiting on <0x445f9d38> (a com.sun.media.sound.EventDispatcher)
at java.lang.Object.wait(Object.java:426)
at com.sun.media.sound.EventDispatcher.dispatchEvents(EventDispatcher.java:294)
- locked <0x445f9d38> (a com.sun.media.sound.EventDispatcher)
at com.sun.media.sound.EventDispatcher.run(EventDispatcher.java:345)
at java.lang.Thread.run(Thread.java:536)
"Signal Dispatcher" daemon prio=1 tid=0x0x807bc50 nid=0x1211 waiting on monitor [0..0]
"Finalizer" daemon prio=1 tid=0x0x8074578 nid=0x120e waiting on monitor [4c2e2000..4c2e286c]
at java.lang.Object.wait(Native Method)
- waiting on <0x445ea290> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
- locked <0x445ea290> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=1 tid=0x0x8073930 nid=0x120d waiting on monitor [4c261000..4c26186c]
at java.lang.Object.wait(Native Method)
- waiting on <0x445ea2f8> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:426)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:113)
- locked <0x445ea2f8> (a java.lang.ref.Reference$Lock)
"main" prio=1 tid=0x0x80515d8 nid=0x120a waiting on monitor [bfffd000..bfffd6fc]
at java.lang.Object.wait(Native Method)
- waiting on <0x445ea310> (a AudioHangDemo)
at java.lang.Object.wait(Object.java:426)
at AudioHangDemo.playClip(AudioHangDemo.java:40)
- locked <0x445ea310> (a AudioHangDemo)
at AudioHangDemo.main(AudioHangDemo.java:50)
"VM Thread" prio=1 tid=0x0x80707b0 nid=0x120c runnable
"VM Periodic Task Thread" prio=1 tid=0x0x807a778 nid=0x120f waiting on monitor
"Suspend Checker Thread" prio=1 tid=0x0x807b1d8 nid=0x1210 runnable
CONFIGURATION
-------------
java version "1.4.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)
I am running on RedHat 7.2, no ALSA, emu10k sound.
- relates to
-
JDK-4498848 Sound causes crashes on Linux
- Resolved
-
JDK-4427864 Merlinb56: Core dump on running Swing Demos on Redhat Linux6.2
- Closed