Hi,

I'm testing a sound-using applet on Fedora 8. Sun JDK 1.6 runs the applet correctly but OpenJDK does not. The applet attempts to open two audio playback lines in succession, without closing the first before attempting to open the second. The first open attempt succeeds but the second attempt fails with:

javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported. at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:511)
        at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:124)
        at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:156)
        at PAPU.start(PAPU.java:198)
        at NES.enableSound(NES.java:390)
        at AppletGui.init(AppletGui.java:38)
        at sun.applet.AppletPanel.run(AppletPanel.java:435)
        at java.lang.Thread.run(Thread.java:674)

The exception message is misleading since the line format is supported. The actual cause of the failure is in:

PLATFORM_API_LinuxOS_ALSA_PCMUtils.c:openPCMfromDeviceID

This call:

    ret = snd_pcm_open(handle, buffer,
                       isSource?SND_PCM_STREAM_PLAYBACK:SND_PCM_STREAM_CAPTURE,
                       SND_PCM_NONBLOCK);

returns the error corresponding to "Device or resource busy".

The attached test case demonstrates the failure.

Tom

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;

public class AudioSystemGetLineTest {
    public static void main(String[] args) throws LineUnavailableException {
        AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, false);
        DataLine.Info info = new DataLine.Info(SourceDataLine.class,
                                               audioFormat, 44100);
        SourceDataLine line = (SourceDataLine)AudioSystem.getLine(info);
        line.open(audioFormat);
        line = (SourceDataLine)AudioSystem.getLine(info);
        line.open(audioFormat);
    }
}

Reply via email to