changeset in /hg/pulseaudio: Moved more methods to DataLine

iivan at town.yyz.redhat.com iivan at town.yyz.redhat.com
Fri Aug 15 13:56:54 PDT 2008


changeset 3f9cc08fdbc0 in /hg/pulseaudio
details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=3f9cc08fdbc0
description:
	Moved more methods to DataLine

diffstat:

4 files changed, 55 insertions(+), 106 deletions(-)
src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java       |   54 +++++++++
src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java          |    2 
src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java |   50 ---------
src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java |   55 ----------

diffs (268 lines):

diff -r 10aa02b5a832 -r 3f9cc08fdbc0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java	Fri Aug 15 16:39:53 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java	Fri Aug 15 16:57:00 2008 -0400
@@ -10,6 +10,7 @@ import javax.sound.sampled.LineEvent;
 import javax.sound.sampled.LineEvent;
 import javax.sound.sampled.LineListener;
 import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.AudioFormat.Encoding;
 
 public abstract class PulseAudioDataLine implements Line {
 
@@ -19,6 +20,7 @@ public abstract class PulseAudioDataLine
 	protected String streamName = "Java Stream";
 	
 	protected boolean isOpen = false;
+	private boolean isPaused = false;
 	protected AudioFormat[] supportedFormats = null;
 	protected AudioFormat currentFormat = null;
 	protected AudioFormat defaultFormat = null;
@@ -88,11 +90,27 @@ public abstract class PulseAudioDataLine
 		}
 	}
 	
+	public void open(AudioFormat format) throws LineUnavailableException {
+		open(format, DEFAULT_BUFFER_SIZE);
+
+	}
+	
+	public void open() throws LineUnavailableException {
+		// pick a random format
+		if (defaultFormat == null) {
+			defaultFormat = new AudioFormat(Encoding.PCM_UNSIGNED, 44100, 8, 2,
+					2, AudioSystem.NOT_SPECIFIED, false);
+		}
+
+		open(defaultFormat, DEFAULT_BUFFER_SIZE);
+	}
+
+	
 	public void close() {
 		assert (isOpen);
 
 		synchronized (eventLoop.threadLock) {
-			stream.drain();
+			//drain();
 			stream.disconnect();
 		}
 
@@ -105,6 +123,35 @@ public abstract class PulseAudioDataLine
 
 	}
 	
+	public void start() {
+		if (isPaused) {
+			stream.cork(false);
+			isPaused = false;
+		}
+
+		/*
+		 * for(LineListener l :listeners) { l.update(new LineEvent(this,
+		 * LineEvent.Type.START, 0)); }
+		 */
+
+	}
+
+	public void stop() {
+		synchronized (eventLoop.threadLock) {
+			stream.cork(true);
+		}
+		isPaused = true;
+
+	}
+	
+	public void addLineListener(LineListener listener) {
+		this.lineListeners.add(listener);
+	}
+
+	public void removeLineListener(LineListener listener) {
+		this.lineListeners.remove(listener);
+	}
+	
 	private void fireLineEvent(LineEvent e) {
 		for (LineListener lineListener : lineListeners) {
 			lineListener.update(e);
@@ -112,6 +159,11 @@ public abstract class PulseAudioDataLine
 	}
 
 	abstract void connectLine();
+	abstract void drain();
+	
+	public boolean isOpen() {
+		return isOpen;
+	}
 
 	
 
diff -r 10aa02b5a832 -r 3f9cc08fdbc0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java	Fri Aug 15 16:39:53 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java	Fri Aug 15 16:57:00 2008 -0400
@@ -304,7 +304,7 @@ public class PulseAudioMixer implements 
 
 		} else {
 			formats = getSupportedFormats();
-			defaultFormat = new AudioFormat(Encoding.PCM_UNSIGNED, 22050, 8, 2,
+			defaultFormat = new AudioFormat(Encoding.PCM_UNSIGNED, 44100, 8, 2,
 					2, AudioSystem.NOT_SPECIFIED, false);
 		}
 
diff -r 10aa02b5a832 -r 3f9cc08fdbc0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Aug 15 16:39:53 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Aug 15 16:57:00 2008 -0400
@@ -52,10 +52,6 @@ public class PulseAudioSourceDataLine ex
 public class PulseAudioSourceDataLine extends PulseAudioDataLine implements SourceDataLine {
 
 
-	private boolean isPaused = false;
-
-
-
 	private Control[] controls = null;
 	private PulseAudioStreamMuteControl muteControl;
 	private PulseAudioStreamVolumeControl volumeControl;
@@ -111,20 +107,6 @@ public class PulseAudioSourceDataLine ex
 		stream.connectForPlayback(null);
 	}
 
-	public void open(AudioFormat format) throws LineUnavailableException {
-		open(format, DEFAULT_BUFFER_SIZE);
-
-	}
-
-	public void open() throws LineUnavailableException {
-		// pick a random format
-		if (defaultFormat == null) {
-			defaultFormat = new AudioFormat(Encoding.PCM_UNSIGNED, 22050, 8, 2,
-					2, AudioSystem.NOT_SPECIFIED, false);
-		}
-
-		open(defaultFormat, DEFAULT_BUFFER_SIZE);
-	}
 
 	@Override
 	public int write(byte[] data, int offset, int length) {
@@ -178,38 +160,6 @@ public class PulseAudioSourceDataLine ex
 		return sizeWritten;
 	}
 
-	public void start() {
-		if (isPaused) {
-			stream.cork(false);
-			isPaused = false;
-		}
-
-		/*
-		 * for(LineListener l :listeners) { l.update(new LineEvent(this,
-		 * LineEvent.Type.START, 0)); }
-		 */
-
-	}
-
-	public void stop() {
-		synchronized (eventLoop.threadLock) {
-			stream.cork(true);
-		}
-		isPaused = true;
-
-	}
-
-	public void addLineListener(LineListener listener) {
-		this.lineListeners.add(listener);
-	}
-
-	public void removeLineListener(LineListener listener) {
-		this.lineListeners.remove(listener);
-	}
-
-	public boolean isOpen() {
-		return isOpen;
-	}
 
 	public int available() {
 		synchronized (eventLoop.threadLock) {
diff -r 10aa02b5a832 -r 3f9cc08fdbc0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java	Fri Aug 15 16:39:53 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java	Fri Aug 15 16:57:00 2008 -0400
@@ -41,7 +41,6 @@ import java.io.IOException;
 import java.io.IOException;
 import java.util.ArrayList;
 import javax.sound.sampled.*;
-import javax.sound.sampled.AudioFormat.Encoding;
 import javax.sound.sampled.Control.Type;
 
 
@@ -83,21 +82,6 @@ public class PulseAudioTargetDataLine ex
 		stream.connectForRecording(null);
 	}
 
-	public void open(AudioFormat format) throws LineUnavailableException {
-		open(format, DEFAULT_BUFFER_SIZE);
-
-	}
-
-	public void open() throws LineUnavailableException {
-		// pick a random format
-		if (defaultFormat == null) {
-			defaultFormat = new AudioFormat(Encoding.PCM_UNSIGNED, 22050, 8, 2,
-					2, AudioSystem.NOT_SPECIFIED, false);
-		}
-
-		open(defaultFormat, DEFAULT_BUFFER_SIZE);
-	}
-
 
 	@Override
 	public int read(byte[] data, int offset, int length) {
@@ -144,32 +128,7 @@ public class PulseAudioTargetDataLine ex
 	
 	}
 
-	private native void readFromStream(byte[] b, int off, int len);
-
-	public void start() {
-		if (isPaused) {
-			resumeStream();
-			isPaused = false;
-		} /*else {
-			startStream();
-		}*/
-
-		/*for (LineListener l : listeners) {
-			l.update(new LineEvent(this, LineEvent.Type.START, 0));
-		}*/
-	}
-
-	public void stop() {
-		//pauseStream();
-		isPaused = true;
-
-	}
-
-	private native void startStream();
-
-	private native void pauseStream();
-
-	private native void resumeStream();
+
 
 	@Override
 	public void drain() {
@@ -181,18 +140,6 @@ public class PulseAudioTargetDataLine ex
 	public void flush() {
 		// TODO Auto-generated method stub
 
-	}
-
-	public void addLineListener(LineListener listener) {
-		lineListeners.add(listener);
-	}
-
-	public void removeLineListener(LineListener listener) {
-		lineListeners.remove(listener);
-	}
-
-	public boolean isOpen() {
-		return isOpen;
 	}
 
 	public int available() {



More information about the distro-pkg-dev mailing list