changeset in /hg/icedtea6: 2008-11-04 Omair Majid <omajid at redh...

Omair Majid omajid at redhat.com
Tue Nov 4 08:02:45 PST 2008


changeset f9592f3296d6 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=f9592f3296d6
description:
	2008-11-04  Omair Majid  <omajid at redhat.com>

	    * Makefile.am (stamps/pulse-java.stamp): Link in libpulse.so after all
	    the object files that use it.
	    * pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java
	    (testWriteIntegralNumberFrames): New function. Tests that a SourceDataLine
	    will only write an integral number of frames.
	    (testWriteNegativeLength): New function. Tests that a
	    SourceDataLine.write() wont accept a negative length.
	    (testWriteNegativeOffset): New function. Tests that a
	    SourceDataLine.write() will not accept a negative offset.
	    (testWriteMoreThanArrayLength): New function. Tests that
	    SourceDataLine.write() wont write more than the length of the array.
	    (testWriteMoreThanArrayLength2): Likewise.
	    (testWriteWithoutStart): Added a check to avoid throwing an
	    IllegalStateException.

diffstat:

3 files changed, 86 insertions(+), 2 deletions(-)
ChangeLog                                                                               |   17 ++
Makefile.am                                                                             |    2 
pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java |   69 +++++++++-

diffs (133 lines):

diff -r 2a9a995b582d -r f9592f3296d6 ChangeLog
--- a/ChangeLog	Tue Nov 04 09:31:55 2008 -0500
+++ b/ChangeLog	Tue Nov 04 11:00:50 2008 -0500
@@ -1,3 +1,20 @@ 2008-11-04  Gary Benson  <gbenson at redhat
+2008-11-04  Omair Majid  <omajid at redhat.com>
+
+	* Makefile.am (stamps/pulse-java.stamp): Link in libpulse.so after all
+	the object files that use it.
+	* pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java
+	(testWriteIntegralNumberFrames): New function. Tests that a SourceDataLine
+	will only write an integral number of frames.
+	(testWriteNegativeLength): New function. Tests that a
+	SourceDataLine.write() wont accept a negative length.
+	(testWriteNegativeOffset): New function. Tests that a
+	SourceDataLine.write() will not accept a negative offset.
+	(testWriteMoreThanArrayLength): New function. Tests that
+	SourceDataLine.write() wont write more than the length of the array.
+	(testWriteMoreThanArrayLength2): Likewise.
+	(testWriteWithoutStart): Added a check to avoid throwing an
+	IllegalStateException.
+
 2008-11-04  Gary Benson  <gbenson at redhat.com>
 
 	* ports/hotspot/src/share/vm/shark/sharkBlock.cpp
diff -r 2a9a995b582d -r f9592f3296d6 Makefile.am
--- a/Makefile.am	Tue Nov 04 09:31:55 2008 -0500
+++ b/Makefile.am	Tue Nov 04 11:00:50 2008 -0500
@@ -1474,7 +1474,7 @@ if ENABLE_PULSE_JAVA
 	$(CC) $(LIBPULSE_CFLAGS) $(CFLAGS) -fPIC -c -I$(ICEDTEA_BOOT_DIR)/include/linux -I$(ICEDTEA_BOOT_DIR)/include $(PULSE_JAVA_NATIVE_SRCDIR)/org_classpath_icedtea_pulseaudio_Stream.c
 	$(CC) $(LIBPULSE_CFLAGS) $(CFLAGS) -fPIC -c -I$(ICEDTEA_BOOT_DIR)/include/linux -I$(ICEDTEA_BOOT_DIR)/include $(PULSE_JAVA_NATIVE_SRCDIR)/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c 
 	$(CC) $(LIBPULSE_CFLAGS) $(CFLAGS) -fPIC -c -I$(ICEDTEA_BOOT_DIR)/include/linux -I$(ICEDTEA_BOOT_DIR)/include $(PULSE_JAVA_NATIVE_SRCDIR)/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c
-	$(CC) $(LDFLAGS) -shared $(LIBPULSE_LIBS) -o libpulse-java.so org_*pulseaudio*.o jni-common.o
+	$(CC) $(LDFLAGS) -shared org_*pulseaudio*.o jni-common.o $(LIBPULSE_LIBS) -o libpulse-java.so 
 	mv org_classpath_icedtea_pulseaudio_*.o $(PULSE_JAVA_CLASS_DIR)
 	mv jni-common.o $(PULSE_JAVA_CLASS_DIR)
 endif
diff -r 2a9a995b582d -r f9592f3296d6 pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java
--- a/pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java	Tue Nov 04 09:31:55 2008 -0500
+++ b/pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java	Tue Nov 04 11:00:50 2008 -0500
@@ -227,6 +227,66 @@ public class PulseAudioSourceDataLineTes
 
 	}
 
+	@Test(expected = IllegalArgumentException.class)
+	public void testWriteIntegralNumberFrames() throws LineUnavailableException {
+		sourceDataLine = (SourceDataLine) mixer.getLine(new Line.Info(
+				SourceDataLine.class));
+
+		/* try writing an non-integral number of frames size */
+		sourceDataLine.open();
+		int frameSize = sourceDataLine.getFormat().getFrameSize();
+		byte[] buffer = new byte[(frameSize * 2) - 1];
+		sourceDataLine.write(buffer, 0, buffer.length);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testWriteNegativeLength() throws LineUnavailableException {
+		sourceDataLine = (SourceDataLine) mixer.getLine(new Line.Info(
+				SourceDataLine.class));
+
+		sourceDataLine.open();
+		int frameSize = sourceDataLine.getFormat().getFrameSize();
+		byte[] buffer = new byte[(frameSize * 2)];
+		/* try writing a negative length */
+		sourceDataLine.write(buffer, 0, -2);
+	}
+
+	@Test(expected = ArrayIndexOutOfBoundsException.class)
+	public void testWriteNegativeOffset() throws LineUnavailableException {
+		sourceDataLine = (SourceDataLine) mixer.getLine(new Line.Info(
+				SourceDataLine.class));
+
+		sourceDataLine.open();
+		int frameSize = sourceDataLine.getFormat().getFrameSize();
+		byte[] buffer = new byte[(frameSize * 2)];
+		/* try writing with a negative offset */
+		sourceDataLine.write(buffer, -1, buffer.length);
+	}
+
+	@Test(expected = ArrayIndexOutOfBoundsException.class)
+	public void testWriteMoreThanArrayLength() throws LineUnavailableException {
+		sourceDataLine = (SourceDataLine) mixer.getLine(new Line.Info(
+				SourceDataLine.class));
+
+		sourceDataLine.open();
+		int frameSize = sourceDataLine.getFormat().getFrameSize();
+		byte[] buffer = new byte[(frameSize * 2)];
+		/* try writing more than the array length */
+		sourceDataLine.write(buffer, 0, frameSize * 3);
+	}
+
+	@Test(expected = ArrayIndexOutOfBoundsException.class)
+	public void testWriteMoreThanArrayLength2() throws LineUnavailableException {
+		sourceDataLine = (SourceDataLine) mixer.getLine(new Line.Info(
+				SourceDataLine.class));
+
+		sourceDataLine.open();
+		int frameSize = sourceDataLine.getFormat().getFrameSize();
+		byte[] buffer = new byte[(frameSize * 2)];
+		/* try writing more than the array length */
+		sourceDataLine.write(buffer, 1, buffer.length);
+	}
+
 	@Test
 	public void testWriteWithoutStart() throws UnsupportedAudioFileException,
 			IOException, LineUnavailableException, InterruptedException {
@@ -253,10 +313,17 @@ public class PulseAudioSourceDataLineTes
 					int total = 0;
 
 					while (bytesRead >= 0 && total < 50) {
+
 						bytesRead = audioInputStream.read(abData, 0,
 								abData.length);
 						if (bytesRead > 0) {
 							sourceDataLine.write(abData, 0, bytesRead);
+						}
+						
+						// when the line is closed (in tearDown),
+						// break out of the loop
+						if (!sourceDataLine.isOpen()) {
+							break;
 						}
 						total++;
 					}
@@ -273,7 +340,7 @@ public class PulseAudioSourceDataLineTes
 
 		Thread.sleep(100);
 
-		writer.join(1000);
+		writer.join(2000);
 
 		/* assert that the writer is still waiting in write */
 		Assert.assertTrue(writer.isAlive());



More information about the distro-pkg-dev mailing list