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

Merge commit '6076046a11d2cd3733e4c7d108b3b26d167ae731' into eclair-mr2-plus-aosp

* commit '6076046a11d2cd3733e4c7d108b3b26d167ae731':
  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 09:56:44 -08:00
committed by Android Git Automerger

View File

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