changeset 35:7dbea4cf0170

fixed conflicts committer: Omair Majid <omajid@redhat.com>
author Omair Majid <omajid@redhat.com>
date Fri, 01 Aug 2008 11:59:27 -0400
parents e48962fa0e8e (current diff) 3e7111680ba6 (diff)
children 73125e09b897
files src/org/openjdk/sound/PulseAudioMixer.java src/org/openjdk/sound/PulseAudioSourceDataLine.java src/org_openjdk_sound_PulseAudioMixer.c src/org_openjdk_sound_PulseAudioSourceDataLine.c
diffstat 4 files changed, 30 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/openjdk/sound/PulseAudioMixer.java	Fri Aug 01 11:54:30 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioMixer.java	Fri Aug 01 11:59:27 2008 -0400
@@ -353,6 +353,16 @@
 		AudioFormat	audioFormat = audioInputStream.getFormat();
 		line.open(audioFormat);
 		line.start();
+		byte[]	abData = new byte[1000];
+		int bytesRead = 0;
+
+		while ( bytesRead >= 0) {
+			bytesRead = audioInputStream.read(abData, 0, abData.length);
+			if (bytesRead > 0) {
+					
+		    		line.write(abData, 0, bytesRead);
+		    	}
+	    }
 		selectedMixer.close();
 		
 
--- a/src/org/openjdk/sound/PulseAudioSourceDataLine.java	Fri Aug 01 11:54:30 2008 -0400
+++ b/src/org/openjdk/sound/PulseAudioSourceDataLine.java	Fri Aug 01 11:59:27 2008 -0400
@@ -16,6 +16,7 @@
 import javax.sound.sampled.Control.Type;
 
 
+
 public class PulseAudioSourceDataLine implements SourceDataLine {
 
 	private static final int DEFAULT_BUFFER_SIZE = 1000;
@@ -43,7 +44,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 length);
 
 	private native int native_get_writable_size();
 
@@ -136,8 +137,12 @@
 		// all the data should have been played by now
 		assert (sizeWritten == length);
 
+		/*
+		 * 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;
-
 	}
 
 	public void start() {
@@ -175,9 +180,6 @@
 		
 			
 			
-			
-		
-
 		/*
 		 * for(LineListener l :listeners) { l.update(new LineEvent(this,
 		 * LineEvent.Type.START, 0)); }
@@ -208,7 +210,11 @@
 		return isOpen;
 	}
 
-	public native int available();
+	public int available() {
+		synchronized(eventLoop.threadLock) {
+			return native_get_writable_size();
+		}
+	};
 
 	public void close() {
 		synchronized (eventLoop.threadLock) {
--- a/src/org_openjdk_sound_PulseAudioSourceDataLine.c	Fri Aug 01 11:54:30 2008 -0400
+++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.c	Fri Aug 01 11:59:27 2008 -0400
@@ -160,13 +160,12 @@
  */
 JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1get_1writable_1size
 (JNIEnv* env, jobject obj) {
-
-	//	jfieldID fid = (*env)->GetIntField
-	//	
-	//	pa_stream* stream = (pa_stream*)streamPointer;
-	//	return pa_stream_writable_size(stream);
-
-}
+	
+	pa_stream *stream = getJavaIntField(env, obj, "streamPointer");
+  	int available = pa_stream_writable_size(stream);
+    
+ }
+	
 
 /*
  * Class:     org_openjdk_sound_PulseAudioSourceDataLine
@@ -233,13 +232,5 @@
 
 }
 
-/*
- * Class:     org_openjdk_sound_PulseAudioSourceDataLine
- * Method:    available
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_available
-(JNIEnv* env, jobject obj) {
 
-}
 
--- a/src/org_openjdk_sound_PulseAudioSourceDataLine.h	Fri Aug 01 11:54:30 2008 -0400
+++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.h	Fri Aug 01 11:59:27 2008 -0400
@@ -20,10 +20,10 @@
 /*
  * Class:     org_openjdk_sound_PulseAudioSourceDataLine
  * Method:    native_write
- * Signature: ([BII)V
+ * Signature: ([BI)V
  */
 JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1write
-  (JNIEnv *, jobject, jbyteArray, jint, jint);
+  (JNIEnv *, jobject, jbyteArray, jint);
 
 /*
  * Class:     org_openjdk_sound_PulseAudioSourceDataLine
@@ -81,14 +81,6 @@
 JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1close
   (JNIEnv *, jobject);
 
-/*
- * Class:     org_openjdk_sound_PulseAudioSourceDataLine
- * Method:    available
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_available
-  (JNIEnv *, jobject);
-
 #ifdef __cplusplus
 }
 #endif