Merge change 2706 into donut

* changes:
  Fix issue 1883666: Audio coming from the music player stopped suddenly
This commit is contained in:
Android (Google) Code Review
2009-05-29 09:40:23 -07:00

View File

@@ -817,9 +817,10 @@ void AudioFlinger::handleForcedSpeakerRoute(int command)
{ {
AutoMutex lock(mHardwareLock); AutoMutex lock(mHardwareLock);
if (mForcedSpeakerCount++ == 0) { if (mForcedSpeakerCount++ == 0) {
mRouteRestoreTime = 0; if (mForcedRoute == 0) {
mMusicMuteSaved = mHardwareMixerThread->streamMute(AudioSystem::MUSIC); mMusicMuteSaved = mHardwareMixerThread->streamMute(AudioSystem::MUSIC);
if (mForcedRoute == 0 && !(mSavedRoute & AudioSystem::ROUTE_SPEAKER)) { LOGV("++mForcedSpeakerCount == 0, mMusicMuteSaved = %d, mRouteRestoreTime = %d", mMusicMuteSaved, mRouteRestoreTime);
if (!(mSavedRoute & AudioSystem::ROUTE_SPEAKER)) {
LOGV("Route forced to Speaker ON %08x", mSavedRoute | AudioSystem::ROUTE_SPEAKER); LOGV("Route forced to Speaker ON %08x", mSavedRoute | AudioSystem::ROUTE_SPEAKER);
mHardwareMixerThread->setStreamMute(AudioSystem::MUSIC, true); mHardwareMixerThread->setStreamMute(AudioSystem::MUSIC, true);
usleep(mHardwareMixerThread->latency()*1000); usleep(mHardwareMixerThread->latency()*1000);
@@ -829,7 +830,9 @@ void AudioFlinger::handleForcedSpeakerRoute(int command)
// delay track start so that audio hardware has time to siwtch routes // delay track start so that audio hardware has time to siwtch routes
usleep(kStartSleepTime); usleep(kStartSleepTime);
} }
}
mForcedRoute = AudioSystem::ROUTE_SPEAKER; mForcedRoute = AudioSystem::ROUTE_SPEAKER;
mRouteRestoreTime = 0;
} }
LOGV("mForcedSpeakerCount incremented to %d", mForcedSpeakerCount); LOGV("mForcedSpeakerCount incremented to %d", mForcedSpeakerCount);
} }