changeset 1155:ce6a731bd3b9

2008-10-24 Omair Majid <omajid@redhat.com> * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java (write): Check for offset being negative. * pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java (testMixerKnowsAboutOpenClips): Removed the assumption that mixer had no other lines open.
author Omair Majid <omajid@redhat.com>
date Fri, 24 Oct 2008 10:10:49 -0400
parents b763518484a6
children 4b16b588ba42
files ChangeLog pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java
diffstat 3 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Oct 24 10:08:18 2008 -0400
+++ b/ChangeLog	Fri Oct 24 10:10:49 2008 -0400
@@ -1,3 +1,11 @@
+2008-10-24  Omair Majid <omajid@redhat.com>
+
+	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
+	(write): Check for offset being negative.
+	* pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java
+	(testMixerKnowsAboutOpenClips): Removed the assumption that mixer had no
+	other lines open.
+
 2008-10-24  Deepak Bhole  <dbhole@redhat.com>
 
 	* plugin/icedtea/netscape/javascript/JSObject.java: Make long constructor
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Oct 24 10:08:18 2008 -0400
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Oct 24 10:10:49 2008 -0400
@@ -153,8 +153,12 @@
 			throw new IllegalArgumentException("length is negative");
 		}
 
+		if (offset < 0) {
+			throw new ArrayIndexOutOfBoundsException("offset is negative: " + offset);
+		}
+		
 		if (length + offset > data.length) {
-			throw new ArrayIndexOutOfBoundsException(length + offset);
+			throw new ArrayIndexOutOfBoundsException("writing data beyond the length of the array: " + (length + offset));
 		}
 
 		int position = offset;
--- a/pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java	Fri Oct 24 10:08:18 2008 -0400
+++ b/pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java	Fri Oct 24 10:10:49 2008 -0400
@@ -605,12 +605,13 @@
 		AudioInputStream audioInputStream1 = AudioSystem
 				.getAudioInputStream(soundFile1);
 
-		Assert.assertEquals(0, mixer.getSourceLines().length);
+		int initiallyOpenClips = mixer.getSourceLines().length;
+		Assert.assertEquals(initiallyOpenClips, mixer.getSourceLines().length);
 		clip.open(audioInputStream1);
-		Assert.assertEquals(1, mixer.getSourceLines().length);
-		Assert.assertEquals(clip, mixer.getSourceLines()[0]);
+		Assert.assertEquals(initiallyOpenClips + 1, mixer.getSourceLines().length);
+		Assert.assertEquals(clip, mixer.getSourceLines()[initiallyOpenClips]);
 		clip.close();
-		Assert.assertEquals(0, mixer.getSourceLines().length);
+		Assert.assertEquals(initiallyOpenClips, mixer.getSourceLines().length);
 
 	}