Here is a testcase. Hope this can be fixed:<br><br>package util.speech;<br><br>import java.util.Iterator;<br>import java.util.Locale;<br>import javax.sound.sampled.AudioFormat;<br>import javax.sound.sampled.AudioSystem;<br>

import javax.sound.sampled.DataLine;<br>import javax.sound.sampled.LineUnavailableException;<br>import javax.sound.sampled.Mixer;<br>import javax.sound.sampled.SourceDataLine;<br>import org.junit.After;<br>import org.junit.AfterClass;<br>

import org.junit.Assume;<br>import org.junit.Before;<br>import org.junit.BeforeClass;<br>import org.junit.Test;<br>import static org.junit.Assert.*;<br><br>/**<br> *<br> * @author i30817<br> */<br>public class VoiceTest {<br>

<br>    <br><br>    public VoiceTest() {<br>    }<br><br>    @BeforeClass<br>    public static void setUpClass() throws Exception {<br>    }<br><br>    @AfterClass<br>    public static void tearDownClass() throws Exception {<br>

    }<br><br>    @Before<br>    public void setUp() {<br>        <br>    }<br><br>    @After<br>    public void tearDown() {<br>    }<br><br>    @Test<br>    public void testDataLineAvailableAndBuggyInJDK() throws LineUnavailableException {<br>

        boolean failedSimpleGetLine = false;<br>        AudioFormat format = new AudioFormat(44100, 16, 2, true, false);<br>        SourceDataLine line = null;<br>        DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);<br>

        try {<br>            line = (SourceDataLine) AudioSystem.getLine(info);<br>        } catch (LineUnavailableException e) {<br>            //ok, at least it says so<br>            throw e;<br>        }<br>        try {<br>

            //if this fails the jdk is very buggy, since it just told us<br>            //the line was available<br>            line.open(format);<br>        } catch (LineUnavailableException e) {<br>            failedSimpleGetLine = true;<br>

        } finally {<br>            if (line.isOpen()) {<br>                line.close();<br>            }<br>        }<br><br><br><br>        //now if this is true, test if it&#39;s possible to get a valid sourcedataline<br>

        //or the only bug is adquiring a sourcedataline doesn&#39;t throw a lineunavailable<br>        //exception before open<br>        Assume.assumeTrue(failedSimpleGetLine);<br>        line = getSourceDataLine(format);<br>

        if (line == null) {<br>            return;<br>        }<br><br>        try {<br>            line.open(format);<br>        } catch (LineUnavailableException e) {<br>            //ok then it is consistent, and there is only one bug<br>

            fail(&quot;Line Unavailable after being adquired&quot;);<br>        } finally {<br>            if (line.isOpen()) {<br>                line.close();<br>            }<br>        }<br>        fail(&quot;line available after first test not managing to adquire it&quot;);<br>

    }<br><br><br>    private SourceDataLine getSourceDataLine(AudioFormat format) {<br>        try {<br>            DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);<br>            for (Mixer.Info mi : AudioSystem.getMixerInfo()) {<br>

                SourceDataLine dataline = null;<br>                try {<br>                    Mixer mixer = AudioSystem.getMixer(mi);<br>                    dataline = (SourceDataLine) mixer.getLine(info);<br>                    dataline.open(format);<br>

                    dataline.start();<br>                    return dataline;<br>                } catch (Exception e) {<br>                }<br>                if (dataline != null) {<br>                    try {<br>                        dataline.close();<br>

                    } catch (Exception e) {<br>                    }<br>                }<br>            }<br>        } catch (Exception e) {<br>        }<br>        return null;<br>    }<br>}<br><br><br><br><div class="gmail_quote">

On Wed, Mar 24, 2010 at 5:56 AM, Paulo Levi <span dir="ltr">&lt;<a href="mailto:i30817@gmail.com">i30817@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Forgot this is when using freetts, but really i expect it to happen with other programs.<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Wed, Mar 24, 2010 at 5:55 AM, Paulo Levi <span dir="ltr">&lt;<a href="mailto:i30817@gmail.com" target="_blank">i30817@gmail.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">This still happens on ubuntu lucid lynx with a recent jdk<br>java version &quot;1.7.0_0-icedtea&quot;<br>



OpenJDK Runtime Environment (IcedTea7 1.11) (7b72-0ubuntu1~ppa1)<br>OpenJDK Client VM (build 17.0-b01, mixed mode, sharing)<br>
<br>in the third post in this thread<br><a href="http://forums.sun.com/thread.jspa?threadID=5189363" target="_blank">http://forums.sun.com/thread.jspa?threadID=5189363</a><br><br>Don&#39;t you guys test sound in linux :(<br>




</blockquote></div><br>
</div></div></blockquote></div><br>