Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52192700 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 2706 into donut

* changes:
  Fix issue 1883666: Audio coming from the music player stopped suddenly
parents ce364705 01c4ba35
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -817,9 +817,10 @@ void AudioFlinger::handleForcedSpeakerRoute(int command)
        {
            AutoMutex lock(mHardwareLock);
            if (mForcedSpeakerCount++ == 0) {
                mRouteRestoreTime = 0;
                if (mForcedRoute == 0) {
                    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);
                        mHardwareMixerThread->setStreamMute(AudioSystem::MUSIC, true);
                        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
                        usleep(kStartSleepTime);
                    }
                }
                mForcedRoute = AudioSystem::ROUTE_SPEAKER;
                mRouteRestoreTime = 0;
            }
            LOGV("mForcedSpeakerCount incremented to %d", mForcedSpeakerCount);
        }