changeset 38:177bc55c9384

fixed problems in playing file; the buffer pointer was being moved beyond the end of the buffer; added functions to make storing and loading ints and longs easier committer: Omair Majid <omajid@redhat.com>
author Omair Majid <omajid@redhat.com>
date Fri, 01 Aug 2008 12:58:52 -0400
parents 73125e09b897
children 92e04ec1b947
files src/jni-common.c src/jni-common.h src/org/openjdk/sound/EventLoop.java src/org/openjdk/sound/PulseAudioMixer.java src/org/openjdk/sound/PulseAudioMixerInfo.java src/org/openjdk/sound/PulseAudioMixerProvider.java src/org/openjdk/sound/PulseAudioSourceDataLine.java src/org/openjdk/sound/PulseAudioStreamVolumeControl.java src/org/openjdk/sound/PulseAudioTargetDataLine.java src/org/openjdk/sound/PulseAudioVolumeControl.java src/org/openjdk/sound/StreamListener.java src/org_openjdk_sound_PulseAudioMixer.h src/org_openjdk_sound_PulseAudioSourceDataLine.c src/org_openjdk_sound_PulseAudioVolumeMuteControl.c
diffstat 14 files changed, 221 insertions(+), 294 deletions(-) [+]
line wrap: on
line diff
--- a/src/jni-common.c	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/jni-common.c	Fri Aug 01 12:58:52 2008 -0400
@@ -1,19 +1,6 @@
 #include "jni-common.h"
 
-void setJavaIntField(JNIEnv *env, jobject obj,char *fieldName, int value) {
-	jclass cls = (*env)->GetObjectClass(env, obj);
-	jfieldID fid =(*env)->GetFieldID(env, cls, fieldName, "I");
-	(*env)->SetIntField(env, obj, fid, value);
-	(*env)->DeleteLocalRef(env, cls);
-}
-
-void* getJavaIntField(JNIEnv* env, jobject obj, char* fieldName) {
-	jclass cls = (*env)->GetObjectClass(env, obj);
-	jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I");
-	jlong value = (*env)->GetIntField(env, obj, fid);
-	(*env)->DeleteLocalRef(env, cls);
-	return (void *) value;
-}
+#include <assert.h>
 
 /*
  * Throw an exception by name
@@ -23,8 +10,42 @@
 	/* if cls is NULL, an exception has already been thrown */
 	if (cls != NULL) {
 		(*env)->ThrowNew(env, cls, msg);
+		return;
 	}
-	/* free the local ref */
-	(*env)->DeleteLocalRef(env, cls);
+}
+
+jint getJavaIntField(JNIEnv* env, jobject obj, char* fieldName) {
+	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I");
+	assert(fid);
+	jint value = (*env)->GetIntField(env, obj, fid);
+	return value;
 }
 
+void setJavaIntField(JNIEnv *env, jobject obj, char *fieldName, jint value) {
+	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	jfieldID fid =(*env)->GetFieldID(env, cls, fieldName, "I");
+	assert(fid);
+	(*env)->SetIntField(env, obj, fid, value);
+}
+
+jlong getJavaLongField(JNIEnv* env, jobject obj, char* name) {
+	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	jfieldID fid = (*env)->GetFieldID(env, cls, name, "J");
+	assert(fid);
+	jint value = (*env)->GetLongField(env, obj, fid);
+	return value;
+
+}
+
+void setJavaLongField(JNIEnv* env, jobject obj, char* name, jlong value) {
+	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	jfieldID fid =(*env)->GetFieldID(env, cls, name, "J");
+	assert(fid);
+	(*env)->SetLongField(env, obj, fid, value);
+}
+
--- a/src/jni-common.h	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/jni-common.h	Fri Aug 01 12:58:52 2008 -0400
@@ -7,9 +7,13 @@
  * 
  */
 
-void* getJavaIntField(JNIEnv* env, jobject obj, char* fieldName);
-void setJavaIntField(JNIEnv* env, jobject obj, char* fieldName, int value);
+jint getJavaIntField(JNIEnv* env, jobject obj, char* fieldName);
+void setJavaIntField(JNIEnv* env, jobject obj, char* fieldName, jint value);
 
-void throwByName(JNIEnv* const env, const char* const name, const char* const msg);
+jlong getJavaLongField(JNIEnv* env, jobject obj, char* name);
+void setJavaLongField(JNIEnv* env, jobject, char* name, jlong value);
+
+void throwByName(JNIEnv* const env, const char* const name,
+		const char* const msg);
 
 #endif
--- a/src/org/openjdk/sound/EventLoop.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/EventLoop.java	Fri Aug 01 12:58:52 2008 -0400
@@ -5,6 +5,8 @@
 import java.util.List;
 import java.util.concurrent.Semaphore;
 
+import javax.sound.sampled.LineUnavailableException;
+
 import org.openjdk.sound.ContextEvent.Type;
 
 /*
@@ -132,40 +134,6 @@
 		return this.status;
 	}
 
-	// public PulseAudioSourceDataLine getLine(Stream s) throws
-	// LineUnavailableException {
-	//
-	// final Semaphore semaphore = new Semaphore(0);
-	//
-	// synchronized (threadLock) {
-	// Stream stream = s;
-	//
-	// stream.addListener(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");
-	// stream.open(contextPointer, "java-stream");
-	// System.out.println("opened testing stream");
-	// }
-	//
-	// try {
-	// semaphore.acquire();
-	// } catch (InterruptedException e) {
-	// throw new LineUnavailableException("unable to prepare stream");
-	// }
-	//
-	// System.out.println(this.getClass().getName() + "stream is ready");
-	//
-	// }
-
 	public void update(int status) {
 		synchronized (threadLock) {
 			System.out.println(this.getClass().getName()
--- a/src/org/openjdk/sound/PulseAudioMixer.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioMixer.java	Fri Aug 01 12:58:52 2008 -0400
@@ -31,19 +31,19 @@
 
 	private boolean isOpen = false;
 
-	 private List<PulseAudioSourceDataLine> _sourceLines = new ArrayList<PulseAudioSourceDataLine>();
-	// private List<PulseAudioTargetDataLine> _targetLines = null;
+	private List<PulseAudioSourceDataLine> sourceLines = new ArrayList<PulseAudioSourceDataLine>();
+	// private List<PulseAudioTargetDataLine> targetLines = null;
 
-	private Line.Info _sourceDataLineInfo = new
-	 Line.Info(PulseAudioSourceDataLine.class);
-	// private Line.Info _targetDataLineInfo = new
+	private Line.Info sourceDataLineInfo = new Line.Info(
+			PulseAudioSourceDataLine.class);
+	// private Line.Info targetDataLineInfo = new
 	// Line.Info(PulseAudioTargetDataLine.class);
 
-	List<LineListener> _lineListeners = null;
+	List<LineListener> lineListeners = null;
 
 	private PulseAudioMixer() {
-		_lineListeners = new ArrayList<LineListener>();
-		// _sourceLines = new ArrayList<PulseAudioSourceDataLine>();
+		lineListeners = new ArrayList<LineListener>();
+		sourceLines = new ArrayList<PulseAudioSourceDataLine>();
 		// _targetLines = new ArrayList<PulseAudioTargetDataLine>();
 	}
 
@@ -62,12 +62,11 @@
 			throw new LineUnavailableException();
 		}
 
-		if ( info.matches(_sourceDataLineInfo)) {
-		PulseAudioSourceDataLine sourceLine = null;
-		// // FIXME : THIS LINE HERE v
-		 sourceLine = new PulseAudioSourceDataLine(eventLoop);
-		_sourceLines.add(sourceLine);
-		return sourceLine;
+		if (info.matches(sourceDataLineInfo)) {
+			PulseAudioSourceDataLine sourceLine = null;
+			sourceLine = new PulseAudioSourceDataLine(eventLoop);
+			sourceLines.add(sourceLine);
+			return sourceLine;
 		}
 
 		// if (info.matches(_targetDataLineInfo)) {
@@ -169,7 +168,7 @@
 
 	@Override
 	public void addLineListener(LineListener listener) {
-		_lineListeners.add(listener);
+		lineListeners.add(listener);
 	}
 
 	@Override
@@ -313,15 +312,15 @@
 
 	@Override
 	synchronized public void removeLineListener(LineListener listener) {
-		_lineListeners.remove(listener);
+		lineListeners.remove(listener);
 	}
 
 	synchronized private void fireEvent(final LineEvent e) {
 		Thread th = new Thread(new Runnable() {
 			@Override
 			public void run() {
-				synchronized (_lineListeners) {
-					for (LineListener lineListener : _lineListeners) {
+				synchronized (lineListeners) {
+					for (LineListener lineListener : lineListeners) {
 						lineListener.update(e);
 					}
 				}
@@ -333,7 +332,7 @@
 	public static void main(String[] args) throws Exception {
 		Mixer.Info mixerInfos[] = AudioSystem.getMixerInfo();
 		Mixer.Info selectedMixerInfo = null;
-//		int i = 0;
+		// int i = 0;
 		for (Mixer.Info info : mixerInfos) {
 			// System.out.println("Mixer Line " + i++ + ": " + info.getName() +
 			// " " + info.getDescription());
@@ -347,24 +346,30 @@
 				.getMixer(selectedMixerInfo);
 
 		selectedMixer.open();
-		SourceDataLine line = (SourceDataLine)selectedMixer.getLine(new Line.Info(PulseAudioSourceDataLine.class));
-		File	soundFile = new File("/home/yyz/omajid/PulseAudio/main-loop/multi-stream/new.wav");
-		AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(soundFile);
-		AudioFormat	audioFormat = audioInputStream.getFormat();
+		SourceDataLine line = (SourceDataLine) selectedMixer
+				.getLine(new Line.Info(PulseAudioSourceDataLine.class));
+
+		System.out.println("got a line");
+
+		File soundFile = new File("new.wav");
+		AudioInputStream audioInputStream = AudioSystem
+				.getAudioInputStream(soundFile);
+		AudioFormat audioFormat = audioInputStream.getFormat();
 		line.open(audioFormat);
 		line.start();
-		byte[]	abData = new byte[1000];
+
+		byte[] abData = new byte[1000];
 		int bytesRead = 0;
 
-		while ( bytesRead >= 0) {
+		while (bytesRead >= 0) {
 			bytesRead = audioInputStream.read(abData, 0, abData.length);
 			if (bytesRead > 0) {
-					
-		    		line.write(abData, 0, bytesRead);
-		    	}
-	    }
+				line.write(abData, 0, bytesRead);
+			}
+		}
+
+		System.out.println("about to close");
 		selectedMixer.close();
-		
 
 	}
 
--- a/src/org/openjdk/sound/PulseAudioMixerInfo.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioMixerInfo.java	Fri Aug 01 12:58:52 2008 -0400
@@ -2,23 +2,24 @@
 
 import javax.sound.sampled.Mixer;
 
-public class PulseAudioMixerInfo extends Mixer.Info{
+public class PulseAudioMixerInfo extends Mixer.Info {
 	// singleton
-	
+
 	private static PulseAudioMixerInfo _instance = null;
-	
-	protected PulseAudioMixerInfo(String name, String vendor, String description, String version) {
+
+	protected PulseAudioMixerInfo(String name, String vendor,
+			String description, String version) {
 		super(name, vendor, description, version);
 	}
 
 	// the "getInstance()" method
 	synchronized public static PulseAudioMixerInfo getInfo() {
-		if ( _instance == null) {
-			_instance = new PulseAudioMixerInfo("PulseAudio Mixer", "openjdk", "the ear-candy mixer", "0.01");
+		if (_instance == null) {
+			_instance = new PulseAudioMixerInfo("PulseAudio Mixer", "openjdk",
+					"the ear-candy mixer", "0.01");
 		}
-		
+
 		return _instance;
 	}
 
-	
 }
--- a/src/org/openjdk/sound/PulseAudioMixerProvider.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioMixerProvider.java	Fri Aug 01 12:58:52 2008 -0400
@@ -1,12 +1,10 @@
-
 package org.openjdk.sound;
 
 import javax.sound.sampled.Mixer;
 import javax.sound.sampled.Mixer.Info;
 
-
-public class PulseAudioMixerProvider extends javax.sound.sampled.spi.MixerProvider {
-	
+public class PulseAudioMixerProvider extends
+		javax.sound.sampled.spi.MixerProvider {
 
 	@Override
 	public Mixer getMixer(Info info) {
@@ -21,9 +19,8 @@
 	@Override
 	public Info[] getMixerInfo() {
 		System.out.println("DEBUG: get mixer info called");
-		Mixer.Info[] m = { PulseAudioMixerInfo.getInfo()};
-		return  m;
+		Mixer.Info[] m = { PulseAudioMixerInfo.getInfo() };
+		return m;
 	}
 
-
 }
--- a/src/org/openjdk/sound/PulseAudioSourceDataLine.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioSourceDataLine.java	Fri Aug 01 12:58:52 2008 -0400
@@ -12,11 +12,8 @@
 import javax.sound.sampled.LineListener;
 import javax.sound.sampled.LineUnavailableException;
 import javax.sound.sampled.SourceDataLine;
-import javax.sound.sampled.AudioFormat.Encoding;
 import javax.sound.sampled.Control.Type;
 
-
-
 public class PulseAudioSourceDataLine implements SourceDataLine {
 
 	private static final int DEFAULT_BUFFER_SIZE = 1000;
@@ -28,8 +25,8 @@
 	private boolean isOpen = false;
 	private boolean isPaused = false;
 
-	private  AudioFormat format = null;
-	
+	private AudioFormat format = null;
+
 	private List<LineListener> listeners;
 
 	/*
@@ -44,7 +41,7 @@
 			String encoding, float rate, int size, int channels,
 			boolean bigEndian, int bufferSize);
 
-	private native void native_write(byte[] data,int offset, int length);
+	private native void native_write(byte[] data, int offset, int length);
 
 	private native int native_get_writable_size();
 
@@ -60,7 +57,6 @@
 
 	private native void native_close();
 
-
 	static {
 		try {
 			String library = new java.io.File(".").getCanonicalPath()
@@ -72,7 +68,7 @@
 		} catch (IOException e) {
 			assert ("Loading failed".endsWith("library"));
 		}
-    }
+	}
 
 	public PulseAudioSourceDataLine(EventLoop eventLoop) {
 		this.eventLoop = eventLoop;
@@ -141,7 +137,6 @@
 		 * FIXME when the stream is flushed() etc, instead of returning length
 		 * this should unblock and return the the size of data written so far
 		 */
-
 		return sizeWritten;
 	}
 
@@ -149,37 +144,36 @@
 		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) {
-				 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();
+
+				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();
+				semaphore.acquire();
 			} catch (InterruptedException e) {
-				//throw new LineUnavailableException("unable to prepare stream");
+				// throw new LineUnavailableException("unable to prepare
+				// stream");
 			}
 			System.out.println(this.getClass().getName() + "stream is ready");
-			}
-		
-			
-			
+		}
+
 		/*
 		 * for(LineListener l :listeners) { l.update(new LineEvent(this,
 		 * LineEvent.Type.START, 0)); }
@@ -201,7 +195,7 @@
 	public void removeLineListener(LineListener listener) {
 		this.listeners.remove(listener);
 	}
-	
+
 	private void addStreamListener(StreamListener listener) {
 		this.streamListeners.add(listener);
 	}
@@ -211,7 +205,7 @@
 	}
 
 	public int available() {
-		synchronized(eventLoop.threadLock) {
+		synchronized (eventLoop.threadLock) {
 			return native_get_writable_size();
 		}
 	};
@@ -288,47 +282,52 @@
 
 	@Override
 	public void drain() {
-		// TODO Auto-generated method stub
+		// TODO: double check this
+		native_drain();
 
 	}
 
 	@Override
 	public void flush() {
-		// TODO Auto-generated method stub
+		// TODO: double check this
+		native_flush();
 
 	}
-	
-    public void update(int status) {
-    	synchronized(eventLoop.threadLock) {
-        System.out.println(this.getClass().getCanonicalName() + ".update() called! status = " + status);
-        switch (status) {
-        case 0:
-                fireEvent(new StreamEvent(org.openjdk.sound.StreamEvent.Type.UNCONNECTED));
-                break;
-        case 1:
-                fireEvent(new StreamEvent(org.openjdk.sound.StreamEvent.Type.CREATING));
-                break;
-        case 2:
-                fireEvent(new StreamEvent(org.openjdk.sound.StreamEvent.Type.READY));
-                break;
-        case 3:
-                fireEvent(new StreamEvent(org.openjdk.sound.StreamEvent.Type.FAILED));
-                break;
-        case 4:
-                break;
-        default:
-                assert ("not supposed to happen".indexOf("false") >= 0);
-        }
-    	}
-    }
-    
-    private void fireEvent(StreamEvent e) {
 
-        for (StreamListener streamListener : streamListeners) {
-                streamListener.update(e);
-        }
-}
+	public void update(int status) {
+		synchronized (eventLoop.threadLock) {
+			System.out.println(this.getClass().getCanonicalName()
+					+ ".update() called! status = " + status);
+			switch (status) {
+			case 0:
+				fireEvent(new StreamEvent(
+						org.openjdk.sound.StreamEvent.Type.UNCONNECTED));
+				break;
+			case 1:
+				fireEvent(new StreamEvent(
+						org.openjdk.sound.StreamEvent.Type.CREATING));
+				break;
+			case 2:
+				fireEvent(new StreamEvent(
+						org.openjdk.sound.StreamEvent.Type.READY));
+				break;
+			case 3:
+				fireEvent(new StreamEvent(
+						org.openjdk.sound.StreamEvent.Type.FAILED));
+				break;
+			case 4:
+				break;
+			default:
+				assert ("not supposed to happen".indexOf("false") >= 0);
+			}
+		}
+	}
 
+	private void fireEvent(StreamEvent e) {
 
+		for (StreamListener streamListener : streamListeners) {
+			streamListener.update(e);
+		}
+	}
 
 }
--- a/src/org/openjdk/sound/PulseAudioStreamVolumeControl.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioStreamVolumeControl.java	Fri Aug 01 12:58:52 2008 -0400
@@ -2,11 +2,10 @@
 
 import java.io.IOException;
 
-
-public class PulseAudioStreamVolumeControl extends PulseAudioVolumeControl{
+public class PulseAudioStreamVolumeControl extends PulseAudioVolumeControl {
 	private long streamPointer;
 	private long mainLoopPointer;
-	
+
 	static {
 		try {
 			String library = new java.io.File(".").getCanonicalPath()
@@ -19,17 +18,20 @@
 			assert ("Loading failed".endsWith("library"));
 		}
 	}
-	
+
 	protected PulseAudioStreamVolumeControl(Type type, float minimum,
 			float maximum, float precision, int updatePeriod,
-			float initialValue, String units, long streamPointer, long mainLoopPointer) {
-		super(type, minimum, maximum, precision, updatePeriod, initialValue, units);
+			float initialValue, String units, long streamPointer,
+			long mainLoopPointer) {
+		super(type, minimum, maximum, precision, updatePeriod, initialValue,
+				units);
 		this.streamPointer = streamPointer;
 		this.mainLoopPointer = mainLoopPointer;
-		
+
 	}
 
 	public native float getValue();
+
 	public native void setValue(float newValue);
 
 }
--- a/src/org/openjdk/sound/PulseAudioTargetDataLine.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioTargetDataLine.java	Fri Aug 01 12:58:52 2008 -0400
@@ -1,14 +1,13 @@
 package org.openjdk.sound;
+
 import java.io.IOException;
 import java.util.ArrayList;
 
 import javax.sound.sampled.*;
 import javax.sound.sampled.Control.Type;
 
-
+public class PulseAudioTargetDataLine implements TargetDataLine {
 
-public class PulseAudioTargetDataLine  implements TargetDataLine {
-	
 	protected long contextPointer;
 	protected long mainLoopPointer;
 	protected long streamPointer;
@@ -16,8 +15,7 @@
 	protected boolean isPaused = false;
 	protected int defaultBufferSize;
 	protected ArrayList<LineListener> listeners;
-	
-	
+
 	static {
 		try {
 			String library = new java.io.File(".").getCanonicalPath()
@@ -30,10 +28,11 @@
 			assert ("Loading failed".endsWith("library"));
 		}
 	}
-	
-	public void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
+
+	public void open(AudioFormat format, int bufferSize)
+			throws LineUnavailableException {
 		isOpen = true;
-		
+
 		int channels = format.getChannels();
 		float rate = format.getSampleRate();
 		int sampleSize = format.getSampleSizeInBits();
@@ -44,32 +43,28 @@
 
 	public void open(AudioFormat format) throws LineUnavailableException {
 		open(format, defaultBufferSize);
-		
+
 	}
-	
 
 	public void open() throws LineUnavailableException {
 		openStream("PCM_SIGNED", 44100, 16, 2, false, defaultBufferSize);
 	}
 
-	private native void openStream(String encoding, float rate, int size, int channels, boolean bigEndian, int bufferSize);
+	private native void openStream(String encoding, float rate, int size,
+			int channels, boolean bigEndian, int bufferSize);
 
 	static {
 		System.loadLibrary("PulseAudioSourceDataLine");
 	}
 
-
-
 	@Override
 	public int read(byte[] b, int off, int len) {
 		readFromStream(b, off, len);
 		return len;
 	}
-	
+
 	private native void readFromStream(byte[] b, int off, int len);
 
-
-
 	public void start() {
 		if (isPaused) {
 			resumeStream();
@@ -77,96 +72,90 @@
 		} else {
 			startStream();
 		}
-		
-		for(LineListener l :listeners) {
+
+		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() {
 		// TODO Auto-generated method stub
-		
+
 	}
 
 	@Override
 	public void flush() {
 		// TODO Auto-generated method stub
-		
+
 	}
-	
-	public void addLineListener(LineListener listener){
+
+	public void addLineListener(LineListener listener) {
 		listeners.add(listener);
 	}
-	
-	public void removeLineListener(LineListener listener){
+
+	public void removeLineListener(LineListener listener) {
 		listeners.remove(listener);
 	}
-	
+
 	public boolean isOpen() {
 		return isOpen;
 	}
-	
+
 	public native int available();
-	
+
 	public void close() {
 		closeStream();
 		for (LineListener l : listeners) {
 			l.update(new LineEvent(this, LineEvent.Type.CLOSE, 0));
 		}
-		
+
 	}
-	
+
 	private native void closeStream();
-	
+
 	public int getBufferSize() {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-
 	public AudioFormat getFormat() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
-
 	public int getFramePosition() {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	
 	public float getLevel() {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-	
 	public long getLongFramePosition() {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-
 	public long getMicrosecondPosition() {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
-
 	public boolean isActive() {
 		// TODO Auto-generated method stub
 		return false;
@@ -176,31 +165,24 @@
 		// TODO Auto-generated method stub
 		return false;
 	}
-	
+
 	public Control getControl(Type control) {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
-
 	public Control[] getControls() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
-
 	public javax.sound.sampled.Line.Info getLineInfo() {
 		return new Line.Info(SourceDataLine.class);
 	}
 
-
 	public boolean isControlSupported(Type control) {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
-	
-
-
-
 }
--- a/src/org/openjdk/sound/PulseAudioVolumeControl.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioVolumeControl.java	Fri Aug 01 12:58:52 2008 -0400
@@ -4,21 +4,14 @@
 import javax.sound.sampled.FloatControl.Type;
 
 public 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);
-		
+		super(type, minimum, maximum, precision, updatePeriod, initialValue,
+				units);
+
 	}
-	
+
 	public native float getMaximum();
-	
-
-	
-	
-	
-	
 
 }
--- a/src/org/openjdk/sound/StreamListener.java	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org/openjdk/sound/StreamListener.java	Fri Aug 01 12:58:52 2008 -0400
@@ -1,6 +1,5 @@
 package org.openjdk.sound;
 
-import javax.sound.sampled.LineListener;
 
 public interface StreamListener{
 
--- a/src/org_openjdk_sound_PulseAudioMixer.h	Fri Aug 01 12:02:49 2008 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class org_openjdk_sound_PulseAudioMixer */
-
-#ifndef _Included_org_openjdk_sound_PulseAudioMixer
-#define _Included_org_openjdk_sound_PulseAudioMixer
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     org_openjdk_sound_PulseAudioMixer
- * Method:    native_initialize
- * Signature: (Ljava/lang/String;Ljava/lang/String;)V
- */
-JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioMixer_native_1initialize
-  (JNIEnv *, jobject, jstring, jstring);
-
-/*
- * Class:     org_openjdk_sound_PulseAudioMixer
- * Method:    native_shutdown
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioMixer_native_1shutdown
-  (JNIEnv *, jobject);
-
-/*
- * Class:     org_openjdk_sound_PulseAudioMixer
- * Method:    native_getStatus
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioMixer_native_1getStatus
-  (JNIEnv *, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
-
--- a/src/org_openjdk_sound_PulseAudioSourceDataLine.c	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.c	Fri Aug 01 12:58:52 2008 -0400
@@ -7,7 +7,6 @@
 #include "org_openjdk_sound_PulseAudioSourceDataLine.h"
 #include "jni-common.h"
 
-
 typedef struct java_context_t {
 	JNIEnv* env;
 	jobject obj;
@@ -146,9 +145,8 @@
 
 	pa_stream* stream = (pa_stream*) (*env)->GetIntField(env, obj, fid);
 	jbyte* data_buffer = (*env)->GetByteArrayElements(env, data, NULL);
-	data_buffer +=offset;
-
-	pa_stream_write(stream, data_buffer, data_length, NULL, 0, PA_SEEK_RELATIVE);
+	jbyte* buffer_start = data_buffer + offset;
+	pa_stream_write(stream, buffer_start, data_length, NULL, 0, PA_SEEK_RELATIVE);
 	(*env)->ReleaseByteArrayElements(env, data, data_buffer, 0);
 
 }
@@ -160,12 +158,11 @@
  */
 JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1get_1writable_1size
 (JNIEnv* env, jobject obj) {
-	
-	pa_stream *stream = getJavaIntField(env, obj, "streamPointer");
-  	int available = pa_stream_writable_size(stream);
-    
- }
-	
+
+	pa_stream *stream = (pa_stream*) getJavaIntField(env, obj, "streamPointer");
+	int available = pa_stream_writable_size(stream);
+
+}
 
 /*
  * Class:     org_openjdk_sound_PulseAudioSourceDataLine
@@ -187,7 +184,6 @@
 	printf("start called\n");
 
 	pa_stream *stream = (pa_stream*)getJavaIntField(env, obj, "streamPointer");
-
 	pa_stream_connect_playback(stream, NULL, NULL, 0, NULL, NULL);
 
 }
@@ -232,5 +228,3 @@
 
 }
 
-
-
--- a/src/org_openjdk_sound_PulseAudioVolumeMuteControl.c	Fri Aug 01 12:02:49 2008 -0400
+++ b/src/org_openjdk_sound_PulseAudioVolumeMuteControl.c	Fri Aug 01 12:58:52 2008 -0400
@@ -1,5 +1,4 @@
-
- void *getJavaLongField(JNIEnv *env, jobject obj, char *fieldName) {
+void *getJavaLongField(JNIEnv *env, jobject obj, char *fieldName) {
 	jclass cls = (*env)->GetObjectClass(env, obj);
 	jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J");
 	jlong value = (*env)->GetLongField(env, obj, fid);
@@ -7,19 +6,20 @@
 	return (void *) value;
 }
 
-static void sink_input_change_volume(pa_context* context, const pa_sink_input_info* input_info, int eol, void* userdata) {
+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;
+	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]);
+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]);
 }