Mercurial > hg > icedtea
changeset 2623:26295314f6d6
PR1741: Fix a few concurrency problems in pulse audio.
2011-06-16 Denis Lila <dlila@redhat.com>
* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java
(addStreamListeners): Remove this.notifyAll() from
openCloseListener.update; change this.notifyAll() to
PulseAudioDataLine.this.notifyAll() in startedListener.update.
* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
(read): Put fragmentBuffer null check in the synchronized block.
(flush): Make it synchronized to avoid race condition with read().
author | Denis Lila <dlila@redhat.com> |
---|---|
date | Thu, 16 Jun 2011 11:11:35 -0400 |
parents | cc35d8ed9124 |
children | b746d080787e |
files | ChangeLog pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java |
diffstat | 3 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Jun 17 16:16:47 2011 -0400 +++ b/ChangeLog Thu Jun 16 11:11:35 2011 -0400 @@ -1,3 +1,13 @@ +2011-06-16 Denis Lila <dlila@redhat.com> + + * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java + (addStreamListeners): Remove this.notifyAll() from + openCloseListener.update; change this.notifyAll() to + PulseAudioDataLine.this.notifyAll() in startedListener.update. + * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java + (read): Put fragmentBuffer null check in the synchronized block. + (flush): Make it synchronized to avoid race condition with read(). + 2011-06-17 Denis Lila <dlila@redhat.com> * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Fri Jun 17 16:16:47 2011 -0400 +++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Thu Jun 16 11:11:35 2011 -0400 @@ -185,11 +185,7 @@ PulseAudioDataLine.this, LineEvent.Type.CLOSE, framesSinceOpen))); } - synchronized (this) { - this.notifyAll(); - } semaphore.release(); - } } } @@ -217,7 +213,7 @@ fireLineEvent(new LineEvent(PulseAudioDataLine.this, LineEvent.Type.START, framesSinceOpen)); synchronized (this) { - this.notifyAll(); + PulseAudioDataLine.this.notifyAll(); } } dataWritten = true;
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Fri Jun 17 16:16:47 2011 -0400 +++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Thu Jun 16 11:11:35 2011 -0400 @@ -184,9 +184,8 @@ */ /* on first read() of the line, fragmentBuffer is null */ - if (fragmentBuffer != null) { - synchronized (this) { - + synchronized (this) { + if (fragmentBuffer != null) { boolean fragmentBufferSmaller = fragmentBuffer.length < length; int smallerBufferLength = Math.min(fragmentBuffer.length, length); @@ -215,7 +214,6 @@ position += bytesRead; remainingLength -= bytesRead; fragmentBuffer = null; - } } @@ -315,11 +313,10 @@ synchronized (this) { drained = true; } - } @Override - public void flush() { + public synchronized void flush() { if (isOpen()) { /* flush the buffer on pulseaudio's side */ @@ -331,11 +328,9 @@ operation.releaseReference(); } - synchronized (this) { - flushed = true; - /* flush the partial fragment we stored */ - fragmentBuffer = null; - } + flushed = true; + /* flush the partial fragment we stored */ + fragmentBuffer = null; } @Override