# HG changeset patch # User Omair Majid # Date 1223496360 14400 # Node ID 5108fc37a89050de8f8f0b3d7beb793cf685fea9 # Parent 66bcf656c0fb79d4ca16262620e243e7208d6b62 2008-10-08 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Removed unused import to get rid of compiler warning. * src/java/org/classpath/icedtea/pulseaudio/Operation.java Likewise. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java (ClipThread.run): Do a sanity check before abusing the value of LOOP_CONTINUOUSLY. (loop): Check the value of the argument. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Removed unused import to get rid of compiler warning. (write): Removed a FIXME, as it is now implemented. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Removed unused import to get rid of compiler warning. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Likewise. * src/java/org/classpath/icedtea/pulseaudio/Stream.java Likewise. diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/EventLoop.java --- a/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java Wed Oct 08 16:06:00 2008 -0400 @@ -37,7 +37,6 @@ package org.classpath.icedtea.pulseaudio; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Semaphore; diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/Operation.java --- a/src/java/org/classpath/icedtea/pulseaudio/Operation.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/Operation.java Wed Oct 08 16:06:00 2008 -0400 @@ -37,7 +37,6 @@ package org.classpath.icedtea.pulseaudio; -import java.io.IOException; /* * Encapsulates a pa_operation object diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Wed Oct 08 16:06:00 2008 -0400 @@ -78,6 +78,17 @@ @Override public void run() { + /* + * The while loop below only works with LOOP_CONTINUOUSLY because we + * abuse the fact that loopsLeft's initial value is -1 + * (=LOOP_CONTINUOUSLY) and it keeps on going lower without hitting + * 0. So do a sanity check + */ + if (Clip.LOOP_CONTINUOUSLY != -1) { + throw new UnsupportedOperationException( + "LOOP_CONTINUOUSLY has changed; things are going to break"); + } + while (true) { writeFrames(currentFrame, endFrame + 1); if (Thread.interrupted()) { @@ -345,8 +356,10 @@ throw new IllegalStateException("Line not open"); } - System.out.println("Loop " + count + " called"); - + if ( count < 0 && count != LOOP_CONTINUOUSLY) { + throw new IllegalArgumentException("invalid value for count:" + count); + } + if (clipThread.isAlive() && count != 0) { // Do nothing; behavior not specified by the Java API return; diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Wed Oct 08 16:06:00 2008 -0400 @@ -44,8 +44,6 @@ import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; -import org.classpath.icedtea.pulseaudio.Operation.State; - public class PulseAudioSourceDataLine extends PulseAudioDataLine implements SourceDataLine, PulseAudioPlaybackLine { @@ -136,7 +134,7 @@ synchronized (this) { writeInterrupted = false; } - + if (!isOpen) { throw new IllegalStateException("must call open() before write()"); } @@ -216,10 +214,6 @@ // all the data should have been played by now assert (sizeWritten == length); - /* - * FIXME when the stream is flushed() etc, instead of returning length - * this should unblock and return the the size of data written so far - */ if (interrupted) { Thread.currentThread().interrupt(); @@ -317,7 +311,7 @@ if (!isOpen) { throw new IllegalStateException("not open so cant close"); } - + writeInterrupted = true; PulseAudioMixer parent = PulseAudioMixer.getInstance(); diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Wed Oct 08 16:06:00 2008 -0400 @@ -37,8 +37,6 @@ package org.classpath.icedtea.pulseaudio; -import java.io.IOException; - import javax.sound.sampled.Port; public class PulseAudioSourcePort extends PulseAudioPort { diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Wed Oct 08 16:06:00 2008 -0400 @@ -37,8 +37,6 @@ package org.classpath.icedtea.pulseaudio; -import java.io.IOException; - import javax.sound.sampled.Port; public class PulseAudioTargetPort extends PulseAudioPort { diff -r 66bcf656c0fb -r 5108fc37a890 src/java/org/classpath/icedtea/pulseaudio/Stream.java --- a/src/java/org/classpath/icedtea/pulseaudio/Stream.java Wed Oct 08 15:27:58 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/Stream.java Wed Oct 08 16:06:00 2008 -0400 @@ -37,7 +37,6 @@ package org.classpath.icedtea.pulseaudio; -import java.io.IOException; import java.util.LinkedList; import java.util.List;