summaryrefslogtreecommitdiffstats
path: root/libs/audioflinger
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2009-05-29 02:03:21 -0700
committerEric Laurent <elaurent@google.com>2009-05-29 02:03:21 -0700
commit01c4ba35637e1c3fbddcb80ce619345812f23c3f (patch)
tree7be144bfbcbc6c7a8d8e327a2aa45e22669561d7 /libs/audioflinger
parentce3647052d06127dc1996391a7d5fdeec6c88b20 (diff)
downloadframeworks_native-01c4ba35637e1c3fbddcb80ce619345812f23c3f.zip
frameworks_native-01c4ba35637e1c3fbddcb80ce619345812f23c3f.tar.gz
frameworks_native-01c4ba35637e1c3fbddcb80ce619345812f23c3f.tar.bz2
Fix issue 1883666: Audio coming from the music player stopped suddenly
The problem comes from the code handling the automatic change of audio routing to speaker when notifications are played. The music is also muted while the sound is forced to speaker. To avoid truncating the end of the notification, a delay is inserted between the end of the notification and the restoration of the audio routing. If a new notification starts during this delay, the current music mute state read and saved before muting music corresponds to the forced mute due to previous notification. When the new notification ends, the mute state restored is muted and music stream stays muted for ever. The fix consists in reading and saving music mute state only if the audio routing has been restored (check that mForcedRoute is back to 0).
Diffstat (limited to 'libs/audioflinger')
-rw-r--r--libs/audioflinger/AudioFlinger.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 13e457f..324111b 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -817,19 +817,22 @@ void AudioFlinger::handleForcedSpeakerRoute(int command)
{
AutoMutex lock(mHardwareLock);
if (mForcedSpeakerCount++ == 0) {
- mRouteRestoreTime = 0;
- mMusicMuteSaved = mHardwareMixerThread->streamMute(AudioSystem::MUSIC);
- if (mForcedRoute == 0 && !(mSavedRoute & AudioSystem::ROUTE_SPEAKER)) {
- LOGV("Route forced to Speaker ON %08x", mSavedRoute | AudioSystem::ROUTE_SPEAKER);
- mHardwareMixerThread->setStreamMute(AudioSystem::MUSIC, true);
- usleep(mHardwareMixerThread->latency()*1000);
- mHardwareStatus = AUDIO_HW_SET_ROUTING;
- mAudioHardware->setRouting(AudioSystem::MODE_NORMAL, mSavedRoute | AudioSystem::ROUTE_SPEAKER);
- mHardwareStatus = AUDIO_HW_IDLE;
- // delay track start so that audio hardware has time to siwtch routes
- usleep(kStartSleepTime);
+ if (mForcedRoute == 0) {
+ mMusicMuteSaved = mHardwareMixerThread->streamMute(AudioSystem::MUSIC);
+ 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);
+ mHardwareStatus = AUDIO_HW_SET_ROUTING;
+ mAudioHardware->setRouting(AudioSystem::MODE_NORMAL, mSavedRoute | AudioSystem::ROUTE_SPEAKER);
+ mHardwareStatus = AUDIO_HW_IDLE;
+ // 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);
}