[Bug 1656] New: PulseAudioSourceDataLine.stop() hangs intermittently due to synchronization problem

bugzilla-daemon at icedtea.classpath.org bugzilla-daemon at icedtea.classpath.org
Sat Jan 25 15:49:13 PST 2014


            Bug ID: 1656
           Summary: PulseAudioSourceDataLine.stop() hangs intermittently
                    due to synchronization problem
    Classification: Unclassified
           Product: IcedTea
           Version: 2.4.4
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P3
         Component: PulseAudio
          Assignee: omajid at redhat.com
          Reporter: sascha.baumeister at mail.com
                CC: unassigned at icedtea.classpath.org

I am using OpenJDK 1.7.0_51, which packages pulse-java.jar version 2.4.4 for
PulseAudio support. I am using Java-Sound in one of my applications, and
noticed massive synchronization problems related to the implementation of

Basically, when using DataLine.stop() and DataLine.start() to pause and then
restart playback, the implementation of PulseAudioDataLine.stop() hangs
intermittently within around a dozen repetitions. I can see that two threads
are hanging:

Thread 1: AWT event-queue
- PulseAudioDataLine.stop() is a synchronized (!) method, and calls
Operation.waitForCompletion() in line 395.
- Operation.waitForCompletion() calls eventLoop.threadLock.wait() in Line 153,
which doesn't happen whenever my application dead-locks

Thread 2: PulseAudio Eventloop Thread
- Thread.run line 744
- EventLoop.run() line 133
- EventLoop.nativeIterate(int)
- Stream.playbackStartedCallback() line 688
- PulseAudioDataLine$3.update() line 215 hangs waiting for synchronization on
the PulseAudioDataLine instance that is locked by Thread 1 because the stop()
method is synchronized.

So if thread 2 is supposed to provide the eventLoop.threadLock.notify() that
thread 1 is waiting for, this will not happen because thread 1 is locking the
PulseAudioDataLine instance in the above szenario. Note again that this is an
intermittent problem, it happens for me on average about once every dozen
stop/restart sequences.

As a side note: you might want to take a serious fresh look at
PulseAudioSourceDataLine.write/stop/close(); the whole implementation seems
highly unsafe with regards to threads, and required me to use a separate
ReentrantLock to separate the stop/close calls of one thread from the write
invocations of another; without it, my application was hanging almost every
time i tried to pause playback ...

Sascha Baumeister
Lecturer in distributed systems at HTW Berlin
Former spec lead JSR 086

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20140125/ebb7efa1/attachment.html 

More information about the distro-pkg-dev mailing list