Here is a testcase. Hope this can be fixed: package util.speech;
import java.util.Iterator; import java.util.Locale; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Mixer; import javax.sound.sampled.SourceDataLine; import org.junit.After; import org.junit.AfterClass; import org.junit.Assume; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; /** * * @author i30817 */ public class VoiceTest { public VoiceTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } @Test public void testDataLineAvailableAndBuggyInJDK() throws LineUnavailableException { boolean failedSimpleGetLine = false; AudioFormat format = new AudioFormat(44100, 16, 2, true, false); SourceDataLine line = null; DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); try { line = (SourceDataLine) AudioSystem.getLine(info); } catch (LineUnavailableException e) { //ok, at least it says so throw e; } try { //if this fails the jdk is very buggy, since it just told us //the line was available line.open(format); } catch (LineUnavailableException e) { failedSimpleGetLine = true; } finally { if (line.isOpen()) { line.close(); } } //now if this is true, test if it's possible to get a valid sourcedataline //or the only bug is adquiring a sourcedataline doesn't throw a lineunavailable //exception before open Assume.assumeTrue(failedSimpleGetLine); line = getSourceDataLine(format); if (line == null) { return; } try { line.open(format); } catch (LineUnavailableException e) { //ok then it is consistent, and there is only one bug fail("Line Unavailable after being adquired"); } finally { if (line.isOpen()) { line.close(); } } fail("line available after first test not managing to adquire it"); } private SourceDataLine getSourceDataLine(AudioFormat format) { try { DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); for (Mixer.Info mi : AudioSystem.getMixerInfo()) { SourceDataLine dataline = null; try { Mixer mixer = AudioSystem.getMixer(mi); dataline = (SourceDataLine) mixer.getLine(info); dataline.open(format); dataline.start(); return dataline; } catch (Exception e) { } if (dataline != null) { try { dataline.close(); } catch (Exception e) { } } } } catch (Exception e) { } return null; } } On Wed, Mar 24, 2010 at 5:56 AM, Paulo Levi <i30...@gmail.com> wrote: > Forgot this is when using freetts, but really i expect it to happen with > other programs. > > > On Wed, Mar 24, 2010 at 5:55 AM, Paulo Levi <i30...@gmail.com> wrote: > >> This still happens on ubuntu lucid lynx with a recent jdk >> java version "1.7.0_0-icedtea" >> OpenJDK Runtime Environment (IcedTea7 1.11) (7b72-0ubuntu1~ppa1) >> OpenJDK Client VM (build 17.0-b01, mixed mode, sharing) >> >> in the third post in this thread >> http://forums.sun.com/thread.jspa?threadID=5189363 >> >> Don't you guys test sound in linux :( >> > >