<Sound Dev> [12] Review Request: 8207150 Clip.isRunning() may return true after Clip.stop() was called
Philip Race
philip.race at oracle.com
Mon Sep 3 23:01:53 UTC 2018
Approved.
-phil.
On 8/4/18, 4:43 PM, Sergey Bylokhov wrote:
> On 03/08/2018 17:44, Phil Race wrote:
>> I don't know what your notation for the race condition means. Please
>> expand and explain in more detail how this happens and add it to the
>> bug report as well as here.
>
> Below some parts of the code which are executed when we play audio in
> write(...) and when we stop the playing.
>
> ====================================================
>>> The problem exists in our DirectAudioDevice implementation. Before
>>> we play the audio we have this check in write():
>>> if (!isActive() && doIO) {
>>> setActive(true);
>>> setStarted(true);
>>> }
>>>
>>> And to stop the clip we have this:
>>> synchronized(lock) {
>>> // need to set doIO to false before notifying the
>>> // read/write thread, that's why isStartedRunning()
>>> // cannot be used
>>> doIO = false;
>>> lock.notifyAll();
>>> }
>>> setActive(false);
>>> setStarted(false);
> ====================================================
>
>>> Note that it is possible to get the next race.
>>> 1 write() -> if(doIO) is true
>>> 2 stop() -> doIO=false + setActive(false) + setStarted(false)
>>> 3 write() -> setActive(true) + setStarted(true)
>
> The notion above means:
> (1) in the write method we execute "if(doIO)" when doIO is true.
> (2) in the stop() method we set doIO to false and call
> setActive(false);
> setStarted(false);
> (3) in the write method we call:
> setActive(true);
> setStarted(true);
>
> So we stop play of audio at step (2) but the clip still reports itself
> as "running".
>
>
More information about the sound-dev
mailing list