changeset 166:c080309b8edd

2008-10-07 Omair Majid <omajid@redhat.com> * src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java (writeFrames): Synchronized the call to notifyAll. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java (addStreamListeners): Likewise.
author Omair Majid <omajid@redhat.com>
date Tue, 07 Oct 2008 14:08:22 -0400
parents d7c213ee6717
children a4ec901897a5
files src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java
diffstat 2 files changed, 15 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java	Tue Oct 07 12:06:29 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioClip.java	Tue Oct 07 14:08:22 2008 -0400
@@ -125,7 +125,9 @@
 		WriteListener writeListener = new WriteListener() {
 			@Override
 			public void update() {
-				eventLoop.threadLock.notifyAll();
+				synchronized (eventLoop.threadLock) {
+					eventLoop.threadLock.notifyAll();
+				}
 			}
 		};
 
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java	Tue Oct 07 12:06:29 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java	Tue Oct 07 14:08:22 2008 -0400
@@ -58,9 +58,8 @@
 	// true between start() and stop()
 	protected boolean isStarted = false;
 
-	//true between a started and an underflow callback
+	// true between a started and an underflow callback
 	protected boolean dataWritten = false;
-	
 
 	// true if a stream has been paused
 	// protected boolean isPaused = false;
@@ -161,10 +160,9 @@
 
 		Stream.UnderflowListener stoppedListener = new Stream.UnderflowListener() {
 			@Override
-			
 			public void update() {
 				dataWritten = false;
-				System.out.println("underflow");
+
 				// always send a STOP event on an underflow (assumption:
 				// an underflow can't happen while the stream is corked)
 				fireLineEvent(new LineEvent(PulseAudioDataLine.this,
@@ -176,10 +174,9 @@
 		Stream.PlaybackStartedListener startedListener = new Stream.PlaybackStartedListener() {
 			@Override
 			public void update() {
-				System.out.println("started callback");
-				
-				//only send a START event in the beginning and following
-				//an underflow
+
+				// only send a START event in the beginning and following
+				// an underflow
 				if (!dataWritten) {
 					fireLineEvent(new LineEvent(PulseAudioDataLine.this,
 							LineEvent.Type.START, framesSinceOpen));
@@ -196,8 +193,9 @@
 
 			@Override
 			public void update() {
-				// System.out.println("can write");
-				eventLoop.threadLock.notifyAll();
+				synchronized (eventLoop.threadLock) {
+					eventLoop.threadLock.notifyAll();
+				}
 			}
 
 		};
@@ -207,8 +205,9 @@
 
 			@Override
 			public void update() {
-
-				eventLoop.threadLock.notifyAll();
+				synchronized (eventLoop.threadLock) {
+					eventLoop.threadLock.notifyAll();
+				}
 			}
 
 		};
@@ -314,10 +313,9 @@
 
 		if (isStarted) {
 			return;
-			
+
 		}
 
-		
 		Operation op;
 		synchronized (eventLoop.threadLock) {
 			op = stream.unCork();
@@ -331,7 +329,6 @@
 		op.releaseReference();
 		isStarted = true;
 
-
 	}
 
 	public synchronized void stop() {
@@ -427,11 +424,6 @@
 
 	public void setName(String streamName) {
 		if (isOpen) {
-			/*
-			 * Note: setting the name of the stream after it's created wont
-			 * work. In fact, it sets the name of the application! This is a bug
-			 * in PulseAudio 0.9.12 but fixed in git.
-			 */
 
 			Operation o;
 			synchronized (eventLoop.threadLock) {