changeset in /hg/pulseaudio: 2008-08-13 Ioana Ivan <iivan at redha...

Ioana Ivan iivan at redhat.com
Tue Sep 2 11:04:35 PDT 2008


changeset fd7d965da555 in /hg/pulseaudio
details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=fd7d965da555
description:
	2008-08-13 Ioana Ivan  <iivan at redhat.com>
	        * src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java:
	                superclass for TargetPort and SourcePort
	        * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java:
	                implements the abstract methods required in PulseAudioPort
	        * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java:
	                implements the abstract methods required in PulseAudioPort
	        * unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java
	        * unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java:
	                new tests

diffstat:

14 files changed, 339 insertions(+), 273 deletions(-)
ChangeLog                                                                |   12 
src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java            |    2 
src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java           |    7 
src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java    |    2 
src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java            |  143 ++++++++++
src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java  |    2 
src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java      |  113 -------
src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java      |  126 --------
src/java/org/classpath/icedtea/pulseaudio/Stream.java                    |    2 
src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c       |   65 +++-
src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c       |   30 --
src/native/org_classpath_icedtea_pulseaudio_Stream.c                     |   10 
unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java |   49 +++
unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java |   49 +++

diffs (truncated from 771 to 500 lines):

diff -r e99d53a7bcfa -r fd7d965da555 ChangeLog
--- a/ChangeLog	Fri Aug 29 16:26:10 2008 -0400
+++ b/ChangeLog	Tue Sep 02 14:02:34 2008 -0400
@@ -1,3 +1,15 @@ 2008-08-13 Ioana Ivan  <iivan at redhat.com
+2008-08-13 Ioana Ivan  <iivan at redhat.com>
+	* src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java:
+		superclass for TargetPort and SourcePort
+	* src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java:
+		implements the abstract methods required in PulseAudioPort
+	* src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java:
+		implements the abstract methods required in PulseAudioPort
+	* unittests/org/classpath/icedtea/pulseaudio/PulseAudioSourcePortTest.java
+	* unittests/org/classpath/icedtea/pulseaudio/PulseAudioTargetPortTest.java:
+		new tests
+
+
 2008-08-13 Ioana Ivan  <iivan at redhat.com>
 
         * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java:
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java	Fri Aug 29 16:26:10 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java	Tue Sep 02 14:02:34 2008 -0400
@@ -352,7 +352,7 @@ public class PulseAudioClip extends Puls
 
 	}
 
-	public int native_setVolume(float value) {
+	public long native_setVolume(float value) {
 		return stream.native_setVolume(value);
 	}
 
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java	Fri Aug 29 16:26:10 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java	Tue Sep 02 14:02:34 2008 -0400
@@ -336,8 +336,12 @@ public class PulseAudioMixer implements 
 			return clip;
 		}
 		
-		if ((info.getLineClass() == Port.class) ) {
+		String portName;
+		boolean isSource;
+		
+		if (Port.Info.class.isInstance(info)) {
 			Port.Info portInfo = (Port.Info) info;
+			portName = portInfo.getName();
 			if(portInfo.isSource()){
 				return new PulseAudioSourcePort(portInfo.getName(), eventLoop);
 			} else {
@@ -346,7 +350,6 @@ public class PulseAudioMixer implements 
 		}
 		
 		
-
 		throw new IllegalArgumentException();
 
 	}
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java	Fri Aug 29 16:26:10 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPlaybackLine.java	Tue Sep 02 14:02:34 2008 -0400
@@ -2,7 +2,7 @@ package org.classpath.icedtea.pulseaudio
 
 interface PulseAudioPlaybackLine {
 	
-	public int native_setVolume(float value);
+	long native_setVolume(float value);
 	
 	boolean isMuted();
 	
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java	Tue Sep 02 14:02:34 2008 -0400
@@ -0,0 +1,143 @@
+package org.classpath.icedtea.pulseaudio;
+
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Control;
+import javax.sound.sampled.FloatControl;
+import javax.sound.sampled.LineEvent;
+import javax.sound.sampled.LineListener;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.Port;
+import javax.sound.sampled.Control.Type;
+
+public abstract class PulseAudioPort extends PulseAudioLine implements Port, PulseAudioPlaybackLine {
+	
+	private String name;
+	private long contextPointer;
+	private EventLoop eventLoop;
+	private int channels;
+	private float volume;
+	private boolean muted;
+	private Control[] controls = null;
+	private PulseAudioMuteControl muteControl;
+	private PulseAudioVolumeControl volumeControl;
+
+	
+	public PulseAudioPort(String name, EventLoop eventLoop) {
+		this.name = name;
+		this.contextPointer = eventLoop.getContextPointer();
+		this.eventLoop = eventLoop;
+		updateVolumeInfo();
+		
+		controls = new Control[2];
+		volumeControl = new PulseAudioVolumeControl(this, eventLoop);
+		controls[0] = volumeControl;
+		muteControl = new PulseAudioMuteControl(this, volumeControl);
+		controls[1] = muteControl;
+		isOpen = true;
+
+		System.out.println("Opened Target Port " + name);
+	}
+	
+	public abstract long native_setVolume(float newValue);
+	
+	public abstract long native_updateVolumeInfo();
+	
+	public boolean isMuted() {
+		return muted;
+	}
+
+	public void setMuted(boolean value) {
+		muted = value;
+	}
+
+	public float getVolume() {
+		return this.volume;
+	}
+
+	public void setVolume(float value) {
+		this.volume = value;
+
+	}
+
+	public synchronized void updateVolumeInfo() {
+		Operation op;
+		synchronized (eventLoop.threadLock) {
+			op = new Operation(native_updateVolumeInfo());
+		}
+
+		op.waitForCompletion();
+		op.releaseReference();
+	}
+
+	public void update_channels_and_volume(int channels, float volume) {
+		this.channels = channels;
+		this.volume = volume;
+	}
+
+
+	@Override
+	public void close() {
+		native_setVolume((float)0);
+		isOpen = false;
+		fireLineEvent(new LineEvent(this,LineEvent.Type.CLOSE, AudioSystem.NOT_SPECIFIED));
+	}
+	
+
+	public Control getControl(Type control) {
+		if (!isOpen) {
+			throw new IllegalArgumentException(
+					"Controls only supported when line is open");
+		}
+
+		for (int i = 0; i < controls.length; i++) {
+			if (controls[i].getType().getClass() == control.getClass()) {
+				return controls[i];
+			}
+		}
+		throw new IllegalArgumentException("Unsupported control type");
+	}
+
+	public Control[] getControls() {
+		if (isOpen) {
+			return controls;
+		} else {
+			return new Control[] {};
+		}
+
+	}
+
+	@Override
+	public abstract  javax.sound.sampled.Line.Info getLineInfo();
+	
+	public boolean isControlSupported(Type control) {
+		for (Control myControl : controls) {
+			if (myControl.getType().getClass() == control.getClass()) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+
+	@Override
+	public void open() throws LineUnavailableException {
+		native_setVolume(volume);
+		isOpen = true;
+		fireLineEvent(new LineEvent(this,LineEvent.Type.OPEN, AudioSystem.NOT_SPECIFIED));
+	}
+	
+   public String getName() {
+	   return this.name;
+   }
+
+	
+
+
+	
+	
+
+}
+
+
+
+
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Aug 29 16:26:10 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Tue Sep 02 14:02:34 2008 -0400
@@ -89,7 +89,7 @@ public class PulseAudioSourceDataLine ex
 
 	}
 	
-	public int  native_setVolume(float value) {
+	public long  native_setVolume(float value) {
 		return stream.native_setVolume(value);
 	}
 	
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java	Fri Aug 29 16:26:10 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java	Tue Sep 02 14:02:34 2008 -0400
@@ -1,113 +1,22 @@ package org.classpath.icedtea.pulseaudio
 package org.classpath.icedtea.pulseaudio;
+import javax.sound.sampled.Port;
 
-import java.util.LinkedList;
-import java.util.List;
 
-import javax.sound.sampled.Control;
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Port;
-import javax.sound.sampled.Control.Type;
 
-public class PulseAudioSourcePort implements Port {
-
-	private String name;
-
-	@SuppressWarnings("unused")
-	private long contextPointer;
-
-	private EventLoop eventLoop;
-
-	private boolean isOpen;
-
-	private List<LineListener> lineListeners = new LinkedList<LineListener>();
-
+public class PulseAudioSourcePort extends PulseAudioPort {
+	
 	public PulseAudioSourcePort(String name, EventLoop eventLoop) {
-		System.out.println("new SourcePort constructed");
-		this.name = name;
-		this.contextPointer = eventLoop.getContextPointer();
-		this.eventLoop = eventLoop;
-		System.out.println("Opened Source Port: " + name);
+		super(name, eventLoop);
 	}
-
-	@Override
-	public void addLineListener(LineListener listener) {
-		synchronized (lineListeners) {
-			lineListeners.add(listener);
-		}
-	}
-
-	@Override
-	public void close() {
-		Operation operation;
-
-//		synchronized (eventLoop.threadLock) {
-//			operation = new Operation(nativeClose());
-//		}
-//
-//		operation.waitForCompletion();
-//		operation.releaseReference();
-
-		isOpen = false;
-	}
-
-	private native long nativeClose();
-
-	@Override
-	public Control getControl(Type control) {
-		throw new IllegalArgumentException(control.toString()
-				+ " not supported");
-	}
-
-	@Override
-	public Control[] getControls() {
-		return new Control[] {};
-	}
-
+	
+	public native long native_setVolume(float newValue);
+	
+	
+	public synchronized  native long native_updateVolumeInfo();
+	
 	@Override
 	public javax.sound.sampled.Line.Info getLineInfo() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	public String getName() {
-		return this.name;
-
-	}
-
-	@Override
-	public boolean isControlSupported(Type control) {
-		return false;
-	}
-
-	@Override
-	public boolean isOpen() {
-		return isOpen;
-	}
-
-	@Override
-	public void open() throws LineUnavailableException {
-		System.out.println("SourcePort opened");
-		Operation operation;
-
-//		synchronized (eventLoop.threadLock) {
-//			operation = new Operation(nativeOpen());
-//		}
-//
-//		operation.waitForCompletion();
-//		operation.releaseReference();
-
-		isOpen = true;
-	}
-
-	private native long nativeOpen();
-
-	@Override
-	public void removeLineListener(LineListener listener) {
-		synchronized (lineListeners) {
-			lineListeners.remove(listener);
-		}
-
+		return new Port.Info(Port.class, getName(), false);
 	}
 
 }
diff -r e99d53a7bcfa -r fd7d965da555 src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java	Fri Aug 29 16:26:10 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java	Tue Sep 02 14:02:34 2008 -0400
@@ -1,132 +1,26 @@ package org.classpath.icedtea.pulseaudio
 package org.classpath.icedtea.pulseaudio;
 
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Control;
-import javax.sound.sampled.FloatControl;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
 import javax.sound.sampled.Port;
-import javax.sound.sampled.Control.Type;
 
-public class PulseAudioTargetPort extends PulseAudioLine implements Port, PulseAudioPlaybackLine {
-	
-	private String name;
-	private long contextPointer;
-	private EventLoop eventLoop;
-	private int channels;
-	private float volume;
-	private boolean muted;
-	private Control[] controls = null;
-	private PulseAudioMuteControl muteControl;
-	private PulseAudioVolumeControl volumeControl;
 
+public class PulseAudioTargetPort extends PulseAudioPort {
 	
 	public PulseAudioTargetPort(String name, EventLoop eventLoop) {
-		this.name = name;
-		this.contextPointer = eventLoop.getContextPointer();
-		this.eventLoop = eventLoop;
-		updateVolumeInfo();
-		
-		controls = new Control[2];
-		volumeControl = new PulseAudioVolumeControl(this, eventLoop);
-		controls[0] = volumeControl;
-		muteControl = new PulseAudioMuteControl(this, volumeControl);
-		controls[1] = muteControl;
-		isOpen = true;
-
-		System.out.println("Opened Target Port " + name);
+		super(name, eventLoop);
 	}
 	
-	public native int native_setVolume(float newValue);
+	public native long native_setVolume(float newValue);
 	
-	public boolean isMuted() {
-		return muted;
+	
+
+	public synchronized  native long native_updateVolumeInfo();
+	
+	@Override
+	public javax.sound.sampled.Line.Info getLineInfo() {
+		return new Port.Info(Port.class, getName(), false);
 	}
 
-	public void setMuted(boolean value) {
-		muted = value;
-	}
 
-	public float getVolume() {
-		return this.volume;
-	}
-
-	public void setVolume(float value) {
-		this.volume = value;
-
-	}
-
-	public synchronized  native int native_updateVolumeInfo();
-	
-	public synchronized void updateVolumeInfo() {
-		Operation op;
-		synchronized (eventLoop.threadLock) {
-			op = new Operation(native_updateVolumeInfo());
-		}
-
-		op.waitForCompletion();
-		op.releaseReference();
-	}
-
-	public void update_channels_and_volume(int channels, float volume) {
-		this.channels = channels;
-		this.volume = volume;
-	}
-
-
-	@Override
-	public void close() {
-		native_setVolume((float)0);
-		isOpen = false;
-		fireLineEvent(new LineEvent(this,LineEvent.Type.CLOSE, AudioSystem.NOT_SPECIFIED));
-	}
-	
-
-	public Control getControl(Type control) {
-		if (!isOpen) {
-			throw new IllegalArgumentException(
-					"Controls only supported when line is open");
-		}
-
-		for (int i = 0; i < controls.length; i++) {
-			if (controls[i].getType().getClass() == control.getClass()) {
-				return controls[i];
-			}
-		}
-		throw new IllegalArgumentException("Unsupported control type");
-	}
-
-	public Control[] getControls() {
-		if (isOpen) {
-			return controls;
-		} else {
-			return new Control[] {};
-		}
-
-	}
-
-	@Override
-	public javax.sound.sampled.Line.Info getLineInfo() {
-		return new Port.Info(Port.class, name, false);
-	}
-
-	public boolean isControlSupported(Type control) {
-		for (Control myControl : controls) {
-			if (myControl.getType().getClass() == control.getClass()) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-
-	@Override
-	public void open() throws LineUnavailableException {
-		native_setVolume(volume);
-		isOpen = true;
-		fireLineEvent(new LineEvent(this,LineEvent.Type.OPEN, AudioSystem.NOT_SPECIFIED));
-	}
 	
 



More information about the distro-pkg-dev mailing list