Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8202264

Race condition in AudioClip.loop()

    XMLWordPrintable

    Details

      Backports

        Description

        AudioClip.loop() may not play sound just after call AudioClip.stop().
        A Java thread for DirectAudioDevice$DirectClip isn't created
        on the folowing cases:

        1) loop() -> isOpen(): true, isActive(): true
        2) stop() -> isOpen(): true, isActive(): false
        3) next loop() -> isOpen(): true, so thread is not created.
        4) CLOSE event -> isOpen(): false, isActive(): false, so thread is stopping
        (thread = null).

        AbstractLine
        +- AbstractDataLine
        +- DirectAudioDevice$DirectDL
        +- DirectAudioDevice$DirectClip

        "Direct Clip" thread is created only when AbstractLine.isOpen() is false.
        And, this thread is stopped at dispatching CLOSE event on Java Sound Event
        Dispatcher thread, if AbstractDataLine.isActive() is false.
        AbstractDataLine.isActive() becomes false at DirectClip.stop(), and
        becomes true at write() on "Direct Clip" thread.

        There is a race condition that "Direct Clip" thread is stopped unexpectedly.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                serb Sergey Bylokhov
                Reporter:
                shadowbug Shadow Bug
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: