changeset 48:f27fbf96d5aa

addeed mute and volume control for SourceDataLine
author iivan@town.yyz.redhat.com
date Fri, 08 Aug 2008 14:40:11 -0400
parents 2785b9eba70d
children bdc766c0c2ae
files makefile src/org/classpath/icedtea/pulseaudio/EventLoop.java src/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java src/org/classpath/icedtea/pulseaudio/PulseAudioMuteControl.java src/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java src/org/classpath/icedtea/pulseaudio/PulseAudioStreamMuteControl.java src/org/classpath/icedtea/pulseaudio/PulseAudioVolumeControl.java src/org/classpath/icedtea/pulseaudio/StreamVolume.java src/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.c src/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.c src/org_classpath_icedtea_pulseaudio_PulseStreamAudioVolumeControl.c
diffstat 11 files changed, 231 insertions(+), 339 deletions(-) [+]
line wrap: on
line diff
--- a/makefile	Fri Aug 08 11:11:03 2008 -0400
+++ b/makefile	Fri Aug 08 14:40:11 2008 -0400
@@ -14,7 +14,7 @@
 
 # Standard targets
 
-all: lib/libpulse-java.so
+all: lib lib/libpulse-java.so
 
 
 clean:
@@ -34,9 +34,8 @@
 lib/libpulse-java.so: \
                       bin/org_classpath_icedtea_pulseaudio_EventLoop.o \
                       bin/org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.o \
-                      bin/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.o \
-                      bin/org_classpath_icedtea_pulseaudio_StreamVolume.o \
-					  bin/jni-common.o  
+                      bin/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.o \
+					 bin/jni-common.o  
 #                      bin/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.o \
 #					  	bin/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.o \      
 	gcc -g -shared -o $@ $^ /usr/lib/libpulse.so
@@ -52,9 +51,6 @@
 bin/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.o: src/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c src/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.h bin
 	gcc $(CFLAGS) $(PLATFORM_FLAGS) -c -o $@ $<
 
-bin/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.o: src/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.c src/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.h
-	gcc $(CFLAGS) $(PLATFORM_FLAGS) -c -o $@ $<
-
 bin/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.o: src/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.c src/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.h
 	gcc $(CFLAGS) $(PLATFORM_FLAGS) -c -o $@ $<
 
@@ -75,9 +71,6 @@
 src/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.h: src/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.class
 	javah -d src -classpath src org.classpath.icedtea.pulseaudio.PulseAudioTargetDataLine
 
-src/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.h: src/org/classpath/icedtea/pulseaudio/PulseAudioVolumeControl.class
-	javah -d src -classpath src org.classpath.icedtea.pulseaudio.PulseAudioVolumeControl
-
 src/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.h: src/org/classpath/icedtea/pulseaudio/PulseAudioStreamVolumeControl.class
 	javah -d src -classpath src org.classpath.icedtea.pulseaudio.PulseAudioStreamVolumeControl
 
--- a/src/org/classpath/icedtea/pulseaudio/EventLoop.java	Fri Aug 08 11:11:03 2008 -0400
+++ b/src/org/classpath/icedtea/pulseaudio/EventLoop.java	Fri Aug 08 14:40:11 2008 -0400
@@ -103,16 +103,17 @@
 	 */
 
 	static {
-		try {
-			String library = new java.io.File(".").getCanonicalPath()
+		//try {
+			/*String library = new java.io.File(".").getCanonicalPath()
 					+ java.io.File.separatorChar + "lib"
 					+ java.io.File.separatorChar
-					+ System.mapLibraryName("pulse-java");
+					+ System.mapLibraryName("pulse-java");*/
+			String library = "/home/yyz/iivan/workspace/pulseaudio/lib/libpulse-java.so";
 			System.out.println(library);
 			System.load(library);
-		} catch (IOException e) {
+		/*} catch (IOException e) {
 			assert ("Loading failed".endsWith("library"));
-		}
+		}*/
 	}
 
 	private EventLoop() {
--- a/src/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java	Fri Aug 08 11:11:03 2008 -0400
+++ b/src/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java	Fri Aug 08 14:40:11 2008 -0400
@@ -47,7 +47,9 @@
 import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioInputStream;
 import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.BooleanControl;
 import javax.sound.sampled.Control;
+import javax.sound.sampled.FloatControl;
 import javax.sound.sampled.DataLine;
 import javax.sound.sampled.Line;
 import javax.sound.sampled.LineEvent;
@@ -101,12 +103,14 @@
 		PulseAudioSourceDataLine sourceLine = null;
 		sourceLine = new PulseAudioSourceDataLine(eventLoop);
 		Line.Info sourceDataLineInfo = sourceLine.getLineInfo();
-		if (info instanceof DataLine.Info) {
+		/*if (info instanceof DataLine.Info) {
 			if (info.matches(sourceDataLineInfo)) {
 				sourceLines.add(sourceLine);
 				return sourceLine;
 			}
-		}
+		}*/
+		
+		return sourceLine;
 
 		// if (info.matches(_targetDataLineInfo)) {
 		// PulseAudioTargetDataLine targetLine = new PulseAudioTargetDataLine();
@@ -114,7 +118,7 @@
 		// return targetLine;
 		// }
 
-		throw new IllegalArgumentException();
+		//throw new IllegalArgumentException();
 	}
 
 	@Override
@@ -426,13 +430,21 @@
 
 		System.out.println("got a line");
 
-		File soundFile = new File("new.wav");
+		//File soundFile = new File(new java.io.File(".").getCanonicalPath() + "/testsounds/logout.wav");
+		File soundFile = new File( "/home/iivan/workspace/pulseaudio/testsounds/logout.wav");
 		AudioInputStream audioInputStream = AudioSystem
 				.getAudioInputStream(soundFile);
 		AudioFormat audioFormat = audioInputStream.getFormat();
 		line.open(audioFormat);
 		line.start();
-
+		PulseAudioStreamVolumeControl control = (PulseAudioStreamVolumeControl) line.getControl(FloatControl.Type.VOLUME);
+		PulseAudioStreamMuteControl mute = (PulseAudioStreamMuteControl) line.getControl(BooleanControl.Type.MUTE);
+		mute.setValue(true);
+		control.setValue(40000);
+		mute.setValue(false);
+		System.out.println("Volume set to " + control.getValue());
+	
+		
 		byte[] abData = new byte[1000];
 		int bytesRead = 0;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/classpath/icedtea/pulseaudio/PulseAudioMuteControl.java	Fri Aug 08 14:40:11 2008 -0400
@@ -0,0 +1,50 @@
+/* PulseAudioMuteControl.java
+   Copyright (C) 2008 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package org.classpath.icedtea.pulseaudio;
+
+import javax.sound.sampled.BooleanControl;
+
+abstract class PulseAudioMuteControl extends BooleanControl {
+
+	protected PulseAudioMuteControl() {
+		super(BooleanControl.Type.MUTE, false, "Volume muted", "Volume on");
+	}
+
+
+}
+
--- a/src/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Aug 08 11:11:03 2008 -0400
+++ b/src/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Fri Aug 08 14:40:11 2008 -0400
@@ -73,11 +73,13 @@
 	private List<AudioFormat> supportedFormats = null;
 	private AudioFormat currentFormat = null;
 
-	private Control[] controls;
-	private Mute muteControl;
-	private StreamVolume volumeControl;
-
 	private List<LineListener> listeners;
+	
+	private Control[] controls = new Control[2];
+	private PulseAudioStreamMuteControl muteControl;
+	private PulseAudioStreamVolumeControl volumeControl;
+	private boolean muted;
+	private float volume;
 
 	/*
 	 * When moving from 32bit platform to 64 bit platform, these variables
@@ -119,18 +121,21 @@
 		} catch (IOException e) {
 			assert ("Loading failed".endsWith("library"));
 		}
+
 	}
+
+	
 	
 	
 	
 
+
 	public PulseAudioSourceDataLine(EventLoop eventLoop) {
 		this.eventLoop = eventLoop;
 		this.listeners = new ArrayList<LineListener>();
+		this.volume = 65536;
 
-		volumeControl = new StreamVolume(this);
-		muteControl = new Mute();
-		controls = new Control[] { volumeControl, muteControl };
+
 
 		/*
 		 * FIXME puselaudio supports any sample rate (it can covert between
@@ -314,8 +319,26 @@
 
 		currentFormat = null;
 
+
 	}
 
+	protected boolean isMuted() {
+		return muted;
+	}
+	
+	protected void setMuted(boolean value) {
+		muted = value;
+	}
+	
+	protected float getVolume() {
+		return this.volume;
+	}
+	
+	protected void setVolume(float value) {
+		this.volume = value;
+		
+	}
+	
 	public void open(AudioFormat format, int bufferSize)
 			throws LineUnavailableException {
 		if (isOpen) {
@@ -332,11 +355,42 @@
 						bufferSize);
 				currentFormat = format;
 				isOpen = true;
-				return;
 			}
 		}
 
-		throw new IllegalArgumentException("invalid format");
+		//throw new IllegalArgumentException("invalid format");
+
+		final Semaphore semaphore = new Semaphore(0);
+
+		synchronized (eventLoop.threadLock) {
+
+			this.addStreamListener(new StreamListener() {
+				@Override
+				public void update(StreamEvent e) {
+					System.out.println(this.getClass().getName()
+							+ " waiting to stream to become ready");
+					if (e.getType() == StreamEvent.Type.READY) {
+						semaphore.release();
+					}
+				}
+			});
+
+			System.out.println("about to open stream");
+			native_start();
+		}
+
+		try {
+			semaphore.acquire();
+		} catch (InterruptedException e) {
+			// throw new LineUnavailableException("unable to prepare
+			// stream");
+		}
+		System.out.println(this.getClass().getName() + "stream is ready");
+		
+		volumeControl = new PulseAudioStreamVolumeControl(this);
+		controls[0] = volumeControl;
+		muteControl = new PulseAudioStreamMuteControl(this);
+		controls[1] = muteControl;
 
 	}
 
@@ -392,40 +446,16 @@
 	}
 
 	public void start() {
-		if (isPaused) {
-			native_resume();
-			isPaused = false;
-			return;
-		} else {
-			final Semaphore semaphore = new Semaphore(0);
-
-			synchronized (eventLoop.threadLock) {
-
-				this.addStreamListener(new StreamListener() {
-					@Override
-					public void update(StreamEvent e) {
-						if (e.getType() == StreamEvent.Type.READY) {
-							semaphore.release();
-						}
-					}
-				});
-
-				native_start();
+			if (isPaused) {
+				native_resume();
+				isPaused = false;
 			}
 
-			try {
-				semaphore.acquire();
-			} catch (InterruptedException e) {
-				// throw new LineUnavailableException("unable to prepare
-				// stream");
-			}
-
-		}
-
 		/*
 		 * for(LineListener l :listeners) { l.update(new LineEvent(this,
 		 * LineEvent.Type.START, 0)); }
 		 */
+	
 	}
 
 	public void stop() {
@@ -513,7 +543,8 @@
 
 	public Control getControl(Type control) {
 		for (int i = 0; i < controls.length; i++) {
-			if (controls[i].getType() == control) {
+			if (controls[i].getType() == control){
+
 				return controls[i];
 			}
 		}
@@ -595,15 +626,12 @@
 			streamListener.update(e);
 		}
 	}
-
-	private class Mute extends BooleanControl {
+	
+	protected EventLoop getEventLoop() {
+		return this.eventLoop;
+	}
+	
 
-		protected Mute() {
-			super(BooleanControl.Type.MUTE, false, "TRUE", "FALSE");
-
-		}
-
-	}
 
 	public long getStreamPointer() {
 		return streamPointer;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/classpath/icedtea/pulseaudio/PulseAudioStreamMuteControl.java	Fri Aug 08 14:40:11 2008 -0400
@@ -0,0 +1,68 @@
+/* PulseAudioStreamMuteControl.java
+   Copyright (C) 2008 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package org.classpath.icedtea.pulseaudio;
+
+import javax.sound.sampled.FloatControl;
+
+public class PulseAudioStreamMuteControl extends PulseAudioMuteControl {
+	
+	private PulseAudioStreamVolumeControl volumeControl;
+	private PulseAudioSourceDataLine line;
+
+	
+	public PulseAudioStreamMuteControl(PulseAudioSourceDataLine line) {
+		this.volumeControl = (PulseAudioStreamVolumeControl) line.getControl(FloatControl.Type.VOLUME);
+		this.line = line;
+	}
+	
+	public synchronized void setValue(boolean value){
+		if (value == true) {
+			line.setMuted(true);
+			volumeControl.setStreamVolume(0);
+		} else {
+			line.setMuted(false);
+			float newValue = volumeControl.getValue();
+			volumeControl.setStreamVolume(newValue);
+		}
+	}
+	
+	public synchronized boolean getValue() {
+		return line.isMuted();
+	}
+
+}
--- a/src/org/classpath/icedtea/pulseaudio/PulseAudioVolumeControl.java	Fri Aug 08 11:11:03 2008 -0400
+++ b/src/org/classpath/icedtea/pulseaudio/PulseAudioVolumeControl.java	Fri Aug 08 14:40:11 2008 -0400
@@ -37,15 +37,14 @@
 
 package org.classpath.icedtea.pulseaudio;
 
+
 import javax.sound.sampled.FloatControl;
 
-public class PulseAudioVolumeControl extends FloatControl {
+abstract class PulseAudioVolumeControl extends FloatControl {
 
-	protected PulseAudioVolumeControl(Type type, float minimum, float maximum,
-			float precision, int updatePeriod, float initialValue, String units) {
-		super(type, minimum, maximum, precision, updatePeriod, initialValue,
-				units);
-
+	protected PulseAudioVolumeControl(PulseAudioSourceDataLine line) {
+		super(FloatControl.Type.VOLUME, 0, 65536, 1, -1, line.getVolume(), "pulseaudio units", "Volume Off", "Default Volume", "Full Volume");
 	}
 
+
 }
--- a/src/org/classpath/icedtea/pulseaudio/StreamVolume.java	Fri Aug 08 11:11:03 2008 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* PulseAudioStreamVolumeControl.java
-   Copyright (C) 2008 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 2.
-
-IcedTea is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with IcedTea; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version.
- */
-
-package org.classpath.icedtea.pulseaudio;
-
-import java.io.IOException;
-
-import javax.sound.sampled.FloatControl;
-
-public class StreamVolume extends FloatControl {
-
-	private FloatControl.Type type;
-	private PulseAudioSourceDataLine stream;
-
-	private static final int MIN_PULSE_VOLUME = 0x0;
-	private static final int MAX_PULSE_VOLUME = 0x10000;
-
-	static {
-		try {
-			String library = new java.io.File(".").getCanonicalPath()
-					+ java.io.File.separatorChar + "lib"
-					+ java.io.File.separatorChar
-					+ System.mapLibraryName("pulse-java");
-			System.out.println(library);
-			System.load(library);
-		} catch (IOException e) {
-			assert ("Loading failed".endsWith("library"));
-		}
-	}
-
-	private native void native_set_volume(int volume, long streamPointer);
-
-	protected StreamVolume(PulseAudioSourceDataLine stream) {
-		super(FloatControl.Type.VOLUME, 0f, 100f, 0.1f, 1, 100f, "percent",
-				"mute", "medium", "max");
-		this.type = FloatControl.Type.VOLUME;
-		this.stream = stream;
-	}
-
-	@Override
-	public float getMaximum() {
-		return super.getMaximum();
-	}
-
-	@Override
-	public float getMinimum() {
-		return super.getMinimum();
-	}
-
-	@Override
-	public Type getType() {
-		return type;
-	}
-
-	@Override
-	public String getUnits() {
-		return super.getUnits();
-	}
-
-	public float getValue() {
-		return super.getValue();
-	}
-
-	public void setValue(float newValue) {
-		/*
-		 * Set value of pulseaudio
-		 * 
-		 */
-		int value = (int) (newValue/100f * MAX_PULSE_VOLUME);
-//		synchronized (eventLoop.threadLock) {
-			native_set_volume(value, stream.getStreamPointer());
-//		}
-		super.setValue(newValue);
-	}
-
-	@Override
-	public void shift(float from, float to, int microseconds) {
-		super.shift(from, to, microseconds);
-	}
-
-}
--- a/src/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.c	Fri Aug 08 11:11:03 2008 -0400
+++ b/src/org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.c	Fri Aug 08 14:40:11 2008 -0400
@@ -41,70 +41,20 @@
 #include "jni-common.h"
 #include "org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.h"
 
-typedef struct {
-	pa_mainloop *mainloop;
-	pa_cvolume *volume;
-} userdata_info;
 
-static void sink_input_info_available(pa_context* context,
-		const pa_sink_input_info* sink_input_info, int eol, void* userdata) {
-	
-	assert(context);
-	
-	if (eol) {
-		return;
-	}
-	assert(sink_input_info);
 
-	(((userdata_info *) userdata)->volume)->channels
-			= sink_input_info->volume.channels;
-	int j;
-	for (j = 0; j < (((userdata_info *)userdata)->volume)->channels; j++) {
-		(((userdata_info *)userdata)->volume)->values[j]
-				= sink_input_info->volume.values[j];
-	}
-//	pa_threaded_mainloop_signal(((userdata_info *) userdata)->mainloop, 0);
- 
-}
 
-/*
- * Class:     org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl
- * Method:    getValue
- * Signature: ()F
- */
-JNIEXPORT jfloat JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl_getValue
-(JNIEnv *env, jobject obj) {
-	pa_stream *stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer");
-	pa_mainloop *mainloop = (pa_mainloop*) getJavaPointer(env, obj, "mainLoopPointer");
-	pa_context *context = pa_stream_get_context(stream);
-	int stream_id = pa_stream_get_index(stream);
-
-	userdata_info *userdata = malloc(sizeof(userdata_info));
-	userdata->mainloop = mainloop;
-	userdata->volume = malloc(sizeof(pa_cvolume));
-//	pa_threaded_mainloop_lock(mainloop);
-	/* pa_operation *o = */ pa_context_get_sink_input_info(context ,stream_id,sink_input_info_available, userdata);
-//	while(pa_operation_get_state(o) != PA_OPERATION_DONE) {
-//		pa_threaded_mainloop_wait(mainloop);
-//	}
-//	pa_operation_unref(o);
-//	pa_threaded_mainloop_unlock(mainloop);
-//	return pa_sw_volume_to_dB(userdata->volume->values[0]);
-	return -0.1;
-}
-
-/*
- * Class:     org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl
- * Method:    setValue
- * Signature: (F)V
- */
-JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl_setValue
-(JNIEnv *env, jobject obj, jfloat new_volume) {
-	pa_stream *stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer");
+JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl_native_1setValue(JNIEnv *env, jobject obj, jfloat new_volume) {
+	printf("IN NATIVE SET VOLUME\n");
+	pa_stream *stream = getJavaPointer(env, obj, "streamPointer");
+	printf("STREAM POINTER %d", (int) stream);
 	pa_context *context = pa_stream_get_context(stream);
 	int stream_id = pa_stream_get_index(stream);
 	int channels = pa_stream_get_sample_spec(stream)->channels;
 	pa_cvolume cv;
-	pa_context_set_sink_input_volume(context, stream_id, pa_cvolume_set(&cv, channels, pa_sw_volume_from_dB(new_volume)), NULL, NULL);
+	return  (jint) pa_context_set_sink_input_volume(context, stream_id, pa_cvolume_set(&cv, channels, new_volume), NULL, NULL);
 }
 
+JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl_native_1getOperationState(JNIEnv *env, jobject obj, jint operation) {
+	return pa_operation_get_state((pa_operation *) operation);
+}
--- a/src/org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.c	Fri Aug 08 11:11:03 2008 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/* org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.c
-   Copyright (C) 2008 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 2.
-
-IcedTea is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with IcedTea; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version.
-*/
-
-
-#include "org_classpath_icedtea_pulseaudio_PulseAudioVolumeControl.h"
\ No newline at end of file
--- a/src/org_classpath_icedtea_pulseaudio_PulseStreamAudioVolumeControl.c	Fri Aug 08 11:11:03 2008 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/* PulseAudioStreamVolumeControl.java
-   Copyright (C) 2008 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 2.
-
-IcedTea is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with IcedTea; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version.
-*/
-
-#include "jni-common.h"
-
-static void sink_input_change_volume(pa_context* context, const pa_sink_input_info* input_info, int eol, void* userdata) {
-	assert(context);
-	if (eol) {
-		return;
-  	}
-	assert(i);
- 	userdata = i->volume;
-}
-
-JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioStreamVolumeControl_getValue(JNIEnv env*, jobject obj)  {
-	 pa_stream *stream = getJavaLongField(env, obj, "streamPointer");
-	 int stream_id pa_stream_get_index(stream);
-	 pa_cvolume *volume;
-	 pa_context_get_sink_input_info((pa_context*) contextPointer ,stream_id,sink_input_change_volume, volume);
-	 printf("%d\n", volume->values[0]);
-}