changeset in /hg/pulseaudio: 2008-09-15 Omair Majid <omajid at redh...
Omair Majid
omajid at redhat.com
Mon Sep 15 13:52:59 PDT 2008
changeset 7ad349ee575d in /hg/pulseaudio
details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=7ad349ee575d
description:
2008-09-15 Omair Majid <omajid at redhat.com>
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java
(connectLine): May throw LineUnavailableException now.
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java
(open): Now rethrows exceptions from connectLine.
(connectLine): Throws LineUnavailableException.
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
(connectLine): Likewise.
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
(connectLine): Likewise.
* src/java/org/classpath/icedtea/pulseaudio/Stream.java
(connectForPlayback): Throws an exception if pa_stream_connect_playback
fails.
(connectForRecording): Throws an exception if pa_stream_connect_record
fails.
* src/native/org_classpath_icedtea_pulseaudio_Stream.c
(Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1connect_1playback):
Dont assert out and die if call to pa_stream_connect_playback fails.
(Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1connect_1record):
Dont assert out and die if the call to pa_stream_connect_record fails.
* unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java
(setUp): Close the mixer if it was open before.
* unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineRawTest.java
(testStartNotificationOnCork): Added a note explaining that this test is
broken.
* unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java
(testDrainTwice): New function. This test drains a mixer twice.
(testFlushTwice): New function. This test flushes a mixer twice.
diffstat:
9 files changed, 60 insertions(+), 12 deletions(-)
src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java | 2
src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java | 14 ++++-
src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java | 2
src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java | 2
src/java/org/classpath/icedtea/pulseaudio/Stream.java | 21 +++++++-
src/native/org_classpath_icedtea_pulseaudio_Stream.c | 3 -
unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java | 3 +
unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineRawTest.java | 1
unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java | 24 ++++++++++
diffs (204 lines):
diff -r cd7041f7a655 -r 7ad349ee575d src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Fri Sep 12 16:28:22 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java Mon Sep 15 16:52:31 2008 -0400
@@ -173,7 +173,7 @@ public class PulseAudioClip extends Puls
}
- protected void connectLine(int bufferSize) {
+ protected void connectLine(int bufferSize) throws LineUnavailableException {
StreamBufferAttributes bufferAttributes = new StreamBufferAttributes(
bufferSize, bufferSize / 2, bufferSize / 2, bufferSize / 2, 0);
diff -r cd7041f7a655 -r 7ad349ee575d src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Fri Sep 12 16:28:22 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Mon Sep 15 16:52:31 2008 -0400
@@ -153,8 +153,15 @@ public abstract class PulseAudioDataLine
stream.addPlaybackStartedListener(startedListener);
- synchronized (eventLoop.threadLock) {
- connectLine(bufferSize);
+ try {
+ synchronized (eventLoop.threadLock) {
+ connectLine(bufferSize);
+ }
+
+ } catch (LineUnavailableException e) {
+ // error connecting to the server!
+ // FIXME clean up
+ throw e;
}
this.bufferSize = bufferSize;
try {
@@ -231,7 +238,8 @@ public abstract class PulseAudioDataLine
return isEngagedInIo;
}
- protected abstract void connectLine(int bufferSize);
+ protected abstract void connectLine(int bufferSize)
+ throws LineUnavailableException;
public abstract void drain();
diff -r cd7041f7a655 -r 7ad349ee575d src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Fri Sep 12 16:28:22 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Mon Sep 15 16:52:31 2008 -0400
@@ -103,7 +103,7 @@ public class PulseAudioSourceDataLine ex
}
- protected void connectLine(int bufferSize) {
+ protected void connectLine(int bufferSize) throws LineUnavailableException {
StreamBufferAttributes bufferAttributes = new StreamBufferAttributes(
bufferSize, bufferSize / 4, bufferSize / 4, bufferSize / 10, 0);
diff -r cd7041f7a655 -r 7ad349ee575d src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Fri Sep 12 16:28:22 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Mon Sep 15 16:52:31 2008 -0400
@@ -74,7 +74,7 @@ public class PulseAudioTargetDataLine ex
parentMixer.addTargetLine(this);
}
- protected void connectLine(int bufferSize) {
+ protected void connectLine(int bufferSize) throws LineUnavailableException {
StreamBufferAttributes bufferAttributes = new StreamBufferAttributes(
bufferSize, 0, 0, 0, bufferSize / 10);
synchronized (eventLoop.threadLock) {
diff -r cd7041f7a655 -r 7ad349ee575d src/java/org/classpath/icedtea/pulseaudio/Stream.java
--- a/src/java/org/classpath/icedtea/pulseaudio/Stream.java Fri Sep 12 16:28:22 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/Stream.java Mon Sep 15 16:52:31 2008 -0400
@@ -40,6 +40,8 @@ import java.io.IOException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
+
+import javax.sound.sampled.LineUnavailableException;
/**
*
@@ -421,31 +423,42 @@ public class Stream {
* @param deviceName
* the device to connect to. use
* <code>null</code for the default device
+ * @throws LineUnavailableException
*/
public void connectForPlayback(String deviceName,
- StreamBufferAttributes bufferAttributes) {
+ StreamBufferAttributes bufferAttributes)
+ throws LineUnavailableException {
int returnValue = native_pa_stream_connect_playback(deviceName,
bufferAttributes.getMaxLength(), bufferAttributes
.getTargetLength(), bufferAttributes.getPreBuffering(),
bufferAttributes.getMinimumRequest(), bufferAttributes
.getFragmentSize(), 0, null, null);
- assert (returnValue == 0);
+ if (returnValue < 0) {
+ throw new LineUnavailableException(
+ "Unable To connect a line for playback");
+ }
}
/**
* Connect the stream to a source.
*
+ * @throws LineUnavailableException
+ *
*/
public void connectForRecording(String deviceName,
- StreamBufferAttributes bufferAttributes) {
+ StreamBufferAttributes bufferAttributes)
+ throws LineUnavailableException {
int returnValue = native_pa_stream_connect_record(deviceName,
bufferAttributes.getMaxLength(), bufferAttributes
.getTargetLength(), bufferAttributes.getPreBuffering(),
bufferAttributes.getMinimumRequest(), bufferAttributes
.getFragmentSize(), 0, null, null);
- assert (returnValue == 0);
+ if (returnValue < 0) {
+ throw new LineUnavailableException(
+ "Unable to connect line for recording");
+ }
}
/**
diff -r cd7041f7a655 -r 7ad349ee575d src/native/org_classpath_icedtea_pulseaudio_Stream.c
--- a/src/native/org_classpath_icedtea_pulseaudio_Stream.c Fri Sep 12 16:28:22 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_Stream.c Mon Sep 15 16:52:31 2008 -0400
@@ -412,7 +412,7 @@ JNIEXPORT jint JNICALL Java_org_classpat
}
}
int value = pa_stream_connect_playback(stream, dev, &buffer_attr, 0, NULL, NULL);
- assert(value >= 0);
+
if (dev != NULL) {
(*env)->ReleaseStringUTFChars(env, device, dev);
dev = NULL;
@@ -456,7 +456,6 @@ JNIEXPORT jint JNICALL Java_org_classpat
}
int value = pa_stream_connect_record(stream, dev, &buffer_attr, flags);
- assert(value >= 0);
if (dev != NULL) {
(*env)->ReleaseStringUTFChars(env, device, dev);
diff -r cd7041f7a655 -r 7ad349ee575d unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java
--- a/unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java Fri Sep 12 16:28:22 2008 -0400
+++ b/unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerRawTest.java Mon Sep 15 16:52:31 2008 -0400
@@ -52,6 +52,9 @@ public class PulseAudioMixerRawTest {
@Before
public void setUp() {
mixer = PulseAudioMixer.getInstance();
+ if (mixer.isOpen()) {
+ mixer.close();
+ }
}
@Test
diff -r cd7041f7a655 -r 7ad349ee575d unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineRawTest.java
--- a/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineRawTest.java Fri Sep 12 16:28:22 2008 -0400
+++ b/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineRawTest.java Mon Sep 15 16:52:31 2008 -0400
@@ -84,6 +84,7 @@ public class PulseAudioSourceDataLineRaw
}
+ // FIXME this test is BROKEN!
@Test
public void testStartNotificationOnCork()
throws UnsupportedAudioFileException, IOException,
diff -r cd7041f7a655 -r 7ad349ee575d unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java
--- a/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java Fri Sep 12 16:28:22 2008 -0400
+++ b/unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLineTest.java Mon Sep 15 16:52:31 2008 -0400
@@ -548,6 +548,30 @@ public class PulseAudioSourceDataLineTes
}
@Test
+ public void testDrainTwice() throws LineUnavailableException {
+ SourceDataLine line = (SourceDataLine) mixer.getLine(new DataLine.Info(
+ SourceDataLine.class, aSupportedFormat, 1000));
+
+ line.open();
+ line.drain();
+ line.drain();
+ line.close();
+
+ }
+
+ @Test
+ public void testFlushTwice() throws LineUnavailableException {
+ SourceDataLine line = (SourceDataLine) mixer.getLine(new DataLine.Info(
+ SourceDataLine.class, aSupportedFormat, 1000));
+
+ line.open();
+ line.flush();
+ line.flush();
+ line.close();
+
+ }
+
+ @Test
public void testMixerKnowsAboutOpenLines() throws LineUnavailableException {
SourceDataLine sourceDataLine = (SourceDataLine) mixer
.getLine(new Line.Info(SourceDataLine.class));
More information about the distro-pkg-dev
mailing list