changeset 141:6201d96f7b94

2008-09-25 Ioana Ivan <iivan@redhat.com> * src/native/org_classpath_icedtea_Stream.c (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1connect_1playback): pass 0 as a flag to pa_stream_connect_playback * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java: formating changes
author Ioana Ivan <iivan@redhat.com>
date Thu, 25 Sep 2008 14:33:45 -0400
parents e29a9eb84a4e
children bfc67049ee9f
files ChangeLog src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java src/native/org_classpath_icedtea_pulseaudio_Stream.c
diffstat 3 files changed, 32 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 24 10:51:53 2008 -0400
+++ b/ChangeLog	Thu Sep 25 14:33:45 2008 -0400
@@ -1,3 +1,12 @@
+2008-09-25 Ioana Ivan <iivan@redhat.com>
+	
+	* src/native/org_classpath_icedtea_Stream.c
+	(Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1connect_1playback):
+	pass 0 as a flag to pa_stream_connect_playback
+
+	* src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java:
+	formating changes
+
 2008-09-23 Ioana Ivan <iivan@redhat.com>
 	* src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java:
 		-split open() into createStream(), addStreamListeners() and
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Wed Sep 24 10:51:53 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Thu Sep 25 14:33:45 2008 -0400
@@ -105,25 +105,25 @@
 
 	}
 
-	protected void connectLine(int bufferSize, Stream masterStream) throws LineUnavailableException {
+	protected void connectLine(int bufferSize, Stream masterStream)
+			throws LineUnavailableException {
 		StreamBufferAttributes bufferAttributes = new StreamBufferAttributes(
 
-				bufferSize, bufferSize / 4, bufferSize / 8,
+		bufferSize, bufferSize / 4, bufferSize / 8,
 				((bufferSize / 10) > 100 ? bufferSize / 10 : 100), 0);
 
-
-		if(masterStream != null) {
+		if (masterStream != null) {
 			synchronized (eventLoop.threadLock) {
-				stream.connectForPlayback(Stream.DEFAULT_DEVICE, bufferAttributes, masterStream.getStreamPointer());
+				stream.connectForPlayback(Stream.DEFAULT_DEVICE,
+						bufferAttributes, masterStream.getStreamPointer());
 			}
 		} else {
 			synchronized (eventLoop.threadLock) {
-				stream.connectForPlayback(Stream.DEFAULT_DEVICE, bufferAttributes, null);
+				stream.connectForPlayback(Stream.DEFAULT_DEVICE,
+						bufferAttributes, null);
 			}
 		}
 	}
-	
-
 
 	@Override
 	public int write(byte[] data, int offset, int length) {
@@ -133,11 +133,10 @@
 			throw new IllegalStateException("must call open() before write()");
 		}
 
-
-		/*if (!isStarted) {
-			throw new IllegalStateException("must call start() before write()");
-		}*/
-
+		/*
+		 * if (!isStarted) { throw new IllegalStateException("must call start()
+		 * before write()"); }
+		 */
 
 		int frameSize = currentFormat.getFrameSize();
 		if (length % frameSize != 0) {
@@ -158,15 +157,13 @@
 
 		int sizeWritten = 0;
 
-	
-
 		boolean interrupted = false;
 
 		while (remainingLength != 0) {
 
 			synchronized (eventLoop.threadLock) {
 				availableSize = stream.getWritableSize();
-			
+
 				do {
 					if (availableSize < 0) {
 						return sizeWritten;
@@ -181,29 +178,25 @@
 						}
 
 					}
-					
+
 					availableSize = stream.getWritableSize();
-					//System.out.println(availableSize);
-					
+					// System.out.println(availableSize);
 
 				} while (availableSize == 0);
-			
 
 				if (availableSize > remainingLength) {
 					availableSize = remainingLength;
 				}
 				/* write a little bit of the buffer */
-		
-					stream.write(data, position, availableSize);
-					//System.out.println("written " + availableSize);
-	
+
+				stream.write(data, position, availableSize);
+				// System.out.println("written " + availableSize);
 
 				sizeWritten += availableSize;
 				position += availableSize;
 				remainingLength -= availableSize;
-				}
 			}
-		
+		}
 
 		// all the data should have been played by now
 		assert (sizeWritten == length);
--- a/src/native/org_classpath_icedtea_pulseaudio_Stream.c	Wed Sep 24 10:51:53 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_Stream.c	Thu Sep 25 14:33:45 2008 -0400
@@ -435,7 +435,10 @@
 			return -1; // oome thrown
 		}
 	}
-	int value = pa_stream_connect_playback(stream, dev, &buffer_attr, PA_STREAM_START_CORKED, NULL, sync_stream);
+	/* Set flags to 0 to fix problem with draining before calling start, might need to
+	be changed back to PA_STREAM_START_CORKED in the future, if we'll be able to implement
+	synchronization*/ 
+	int value = pa_stream_connect_playback(stream, dev, &buffer_attr, 0, NULL, sync_stream);
 
 	if (dev != NULL) {
 		(*env)->ReleaseStringUTFChars(env, device, dev);