# HG changeset patch # User Omair Majid # Date 1223321815 14400 # Node ID fa7dd0d762f1fd82db5d3ba52ac9eab5802da1ee # Parent 86fab9e2bc643a8798044b55d4bec50716742ec4 2008-10-06 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java (open): Synchronized method. (native_setVolume): Synchronized native method on eventLoop. (setVolume): Synchronized method. (write): Set flushed to false on initialization, and false when handling the flush. (close): Synchronized method. diff -r 86fab9e2bc64 -r fa7dd0d762f1 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Mon Oct 06 15:30:33 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java Mon Oct 06 15:36:55 2008 -0400 @@ -51,7 +51,7 @@ private PulseAudioVolumeControl volumeControl; private boolean muted; private float volume; - + boolean flushed = false; boolean drained = false; @@ -67,7 +67,7 @@ } @Override - public void open(AudioFormat format, int bufferSize) + synchronized public void open(AudioFormat format, int bufferSize) throws LineUnavailableException { super.open(format, bufferSize); @@ -88,7 +88,9 @@ } public byte[] native_setVolume(float value) { - return stream.native_setVolume(value); + synchronized (eventLoop.threadLock) { + return stream.native_setVolume(value); + } } public boolean isMuted() { @@ -103,7 +105,7 @@ return this.volume; } - public void setVolume(float value) { + synchronized public void setVolume(float value) { this.volume = value; } @@ -155,20 +157,22 @@ int sizeWritten = 0; + flushed = false; + boolean interrupted = false; while (remainingLength != 0) { synchronized (this) { - - if (!isStarted || !isOpen) { + + if (!isStarted || !isOpen) { return sizeWritten; } - + if (flushed) { + flushed = false; return sizeWritten; } - synchronized (eventLoop.threadLock) { @@ -264,7 +268,7 @@ operation.waitForCompletion(); operation.releaseReference(); - + synchronized (this) { drained = true; } @@ -287,13 +291,13 @@ operation.releaseReference(); synchronized (this) { - flushed= true; + flushed = true; } - + } @Override - public void close() { + synchronized public void close() { if (!isOpen) { throw new IllegalStateException("not open so cant close"); }