# HG changeset patch # User Omair Majid # Date 1222205007 14400 # Node ID 438aa072a80d087c12df8f2a47892b0136e70de4 # Parent 2d384ad19c3e849c06a484b05c360545240ecfb1# Parent 6409aaedc201b977217b46d8ab4a9c744bd1a185 2008-09-23 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Merged changes. diff -r 2d384ad19c3e -r 438aa072a80d README --- a/README Tue Sep 23 17:01:26 2008 -0400 +++ b/README Tue Sep 23 17:23:27 2008 -0400 @@ -19,6 +19,10 @@ Where does it come from? All of the code was written by the authors -The sound files (new.wav and logout.wav) were taken from +The sound files new.wav and logout.wav were taken from http://websvn.kde.org/branches/KDE/4.0/kdeartwork/sounds/ (and renamed). They are licensed by the copyright holders as GPLv2. + +The sound file error.wav is part of gnome-audio +http://ftp.gnome.org/pub/gnome/sources/gnome-audio/2.22/gnome-audio-2.22.2.tar.bz2 +It is licensed under the LGPL by the copyright holders. diff -r 2d384ad19c3e -r 438aa072a80d src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Tue Sep 23 17:01:26 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Tue Sep 23 17:23:27 2008 -0400 @@ -81,7 +81,7 @@ @Override public void run() { - while (loopsLeft >= 0) { + while (true) { writeFrames(currentFrame, endFrame + 1); if (Thread.interrupted()) { // Thread.currentThread().interrupt(); diff -r 2d384ad19c3e -r 438aa072a80d testsounds/error.wav Binary file testsounds/error.wav has changed diff -r 2d384ad19c3e -r 438aa072a80d unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java --- a/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java Tue Sep 23 17:01:26 2008 -0400 +++ b/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java Tue Sep 23 17:23:27 2008 -0400 @@ -138,6 +138,50 @@ clip.close(); } + + + @Test + public void testLoopContinuously() throws LineUnavailableException, + IOException, UnsupportedAudioFileException, InterruptedException { + System.out + .println("This tests loop(LOOP_CONTINUOUSLY) on the Clip"); + final Clip clip = (Clip) mixer.getLine(new Line.Info(Clip.class)); + File soundFile = new File("testsounds/error.wav"); + AudioInputStream audioInputStream = AudioSystem + .getAudioInputStream(soundFile); + clip.open(audioInputStream); + + clip.setLoopPoints((int) (clip.getFrameLength() / 4), (int) (clip + .getFrameLength() / 2)); + clip.loop(Clip.LOOP_CONTINUOUSLY); + + Runnable blocker = new Runnable() { + + @Override + public void run() { + clip.drain(); + } + + }; + + Thread th = new Thread(blocker); + th.start(); + th.join(10000); + + if (!th.isAlive()) { + clip.close(); + Assert.fail("LOOP_CONTINUOUSLY doesnt seem to work"); + } + + clip.stop(); + th.join(500); + if ( th.isAlive()) { + clip.close(); + Assert.fail("stopping LOOP_CONTINUOSLY failed"); + } + + clip.close(); + } @Test public void testIsActiveAndIsOpen() throws LineUnavailableException,