OSDN Git Service

Fix bug 4109988 fix deadlock on destroy
authorJean-Michel Trivi <jmtrivi@google.com>
Sat, 19 Mar 2011 00:02:17 +0000 (17:02 -0700)
committerJean-Michel Trivi <jmtrivi@google.com>
Mon, 21 Mar 2011 18:53:05 +0000 (11:53 -0700)
commit9e0e6e5c60320dac9aa2abbce2f9a843b8fc4449
tree7dc1ba1e4378b105a38ed1b84653a6958e4946e8
parentc5dcfeb20f3d94d0d8c1a5e875e531c0929358cf
Fix bug 4109988 fix deadlock on destroy

Fix deadlock with an AudioPlayer playing from a PCM buffer queue.
This type of player uses an AudioTrack that pulls data through
 its callback from a buffer queue.
This issue is that when you destroy the player (whick locks the
 object), it tries to destroy the AudioTrack object. The
 AudioTrack destructor can only finish when the AudioTrack
 callback thread can exit. If a callback was underway when
 trying to destroy the object, a race condition existed for
 the AudioPlayer lock.
The fix consists in using the "pre-destroy" hook for the AudioPlayer
 object. In it, we unlock the AudioPlayer, and block until the
 AudioTrack callback has signaled it's done. The pre-destroy
 hook also marks the track as "about to be destroyed" so any
 callback that gets called once the pre-destroy hook has been
 called can return immediately.

Change-Id: I4ca69157ff381232c1edc8fb576c6d9e90c2777f
wilhelm/src/Android.mk
wilhelm/src/android/AudioPlayer_to_android.cpp
wilhelm/src/android/AudioPlayer_to_android.h
wilhelm/src/android/AudioTrackProtector.cpp [new file with mode: 0644]
wilhelm/src/android/AudioTrackProtector.h [new file with mode: 0644]
wilhelm/src/classes.h
wilhelm/src/itf/IEngine.c
wilhelm/src/objects/CAudioPlayer.c
wilhelm/src/sles_allinclusive.h