Merge change 9340 into donut
* changes: Fix issue 2025872: Deadlock in SoundPool.stop
This commit is contained in:
@@ -93,7 +93,7 @@ SoundPool::~SoundPool()
|
|||||||
|
|
||||||
void SoundPool::addToRestartList(SoundChannel* channel)
|
void SoundPool::addToRestartList(SoundChannel* channel)
|
||||||
{
|
{
|
||||||
Mutex::Autolock lock(&mLock);
|
Mutex::Autolock lock(&mRestartLock);
|
||||||
mRestart.push_back(channel);
|
mRestart.push_back(channel);
|
||||||
mCondition.signal();
|
mCondition.signal();
|
||||||
}
|
}
|
||||||
@@ -106,9 +106,9 @@ int SoundPool::beginThread(void* arg)
|
|||||||
|
|
||||||
int SoundPool::run()
|
int SoundPool::run()
|
||||||
{
|
{
|
||||||
mLock.lock();
|
mRestartLock.lock();
|
||||||
while (!mQuit) {
|
while (!mQuit) {
|
||||||
mCondition.wait(mLock);
|
mCondition.wait(mRestartLock);
|
||||||
LOGV("awake");
|
LOGV("awake");
|
||||||
if (mQuit) break;
|
if (mQuit) break;
|
||||||
|
|
||||||
@@ -125,19 +125,19 @@ int SoundPool::run()
|
|||||||
|
|
||||||
mRestart.clear();
|
mRestart.clear();
|
||||||
mCondition.signal();
|
mCondition.signal();
|
||||||
mLock.unlock();
|
mRestartLock.unlock();
|
||||||
LOGV("goodbye");
|
LOGV("goodbye");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundPool::quit()
|
void SoundPool::quit()
|
||||||
{
|
{
|
||||||
mLock.lock();
|
mRestartLock.lock();
|
||||||
mQuit = true;
|
mQuit = true;
|
||||||
mCondition.signal();
|
mCondition.signal();
|
||||||
mCondition.wait(mLock);
|
mCondition.wait(mRestartLock);
|
||||||
LOGV("return from quit");
|
LOGV("return from quit");
|
||||||
mLock.unlock();
|
mRestartLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundPool::startThreads()
|
bool SoundPool::startThreads()
|
||||||
@@ -484,11 +484,8 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV
|
|||||||
// if not idle, this voice is being stolen
|
// if not idle, this voice is being stolen
|
||||||
if (mState != IDLE) {
|
if (mState != IDLE) {
|
||||||
LOGV("channel %d stolen - event queued for channel %d", channelID(), nextChannelID);
|
LOGV("channel %d stolen - event queued for channel %d", channelID(), nextChannelID);
|
||||||
stop_l();
|
|
||||||
mNextEvent.set(sample, nextChannelID, leftVolume, rightVolume, priority, loop, rate);
|
mNextEvent.set(sample, nextChannelID, leftVolume, rightVolume, priority, loop, rate);
|
||||||
#ifdef USE_SHARED_MEM_BUFFER
|
stop();
|
||||||
mSoundPool->done(this);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ private:
|
|||||||
|
|
||||||
jobject mSoundPoolRef;
|
jobject mSoundPoolRef;
|
||||||
Mutex mLock;
|
Mutex mLock;
|
||||||
|
Mutex mRestartLock;
|
||||||
Condition mCondition;
|
Condition mCondition;
|
||||||
SoundPoolThread* mDecodeThread;
|
SoundPoolThread* mDecodeThread;
|
||||||
SoundChannel* mChannelPool;
|
SoundChannel* mChannelPool;
|
||||||
|
|||||||
Reference in New Issue
Block a user