am 52d390e8: am 6076046a: am 1ac56b60: Merge change Iac196e17 into eclair

Merge commit '52d390e8892967c1fad717a00731c0a25e268686'

* commit '52d390e8892967c1fad717a00731c0a25e268686':
  Fix issue 2292062: Audio freezes for three seconds when choosing ringtones with a headset connected and music playing.
This commit is contained in:
Eric Laurent 2009-12-02 20:28:16 -08:00 committed by Android Git Automerger
commit 0dd59f0022

View File

@ -2277,10 +2277,8 @@ AudioFlinger::PlaybackThread::Track::~Track()
LOGV("PlaybackThread::Track destructor");
sp<ThreadBase> thread = mThread.promote();
if (thread != 0) {
thread->mLock.lock();
Mutex::Autolock _l(thread->mLock);
mState = TERMINATED;
thread->mLock.unlock();
AudioSystem::releaseOutput(thread->id());
}
}
@ -2298,8 +2296,11 @@ void AudioFlinger::PlaybackThread::Track::destroy()
{ // scope for mLock
sp<ThreadBase> thread = mThread.promote();
if (thread != 0) {
if (!isOutputTrack() && (mState == ACTIVE || mState == RESUMING)) {
AudioSystem::stopOutput(thread->id(), (AudioSystem::stream_type)mStreamType);
if (!isOutputTrack()) {
if (mState == ACTIVE || mState == RESUMING) {
AudioSystem::stopOutput(thread->id(), (AudioSystem::stream_type)mStreamType);
}
AudioSystem::releaseOutput(thread->id());
}
Mutex::Autolock _l(thread->mLock);
PlaybackThread *playbackThread = (PlaybackThread *)thread.get();