From 89e74ba1419732dd5c7f939e48d4aa7989fd3a51 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 30 Sep 2009 18:26:36 -0700 Subject: [PATCH] Fix Issue 2158631: AudioService: volume control sometimes not restored after media server process crash. The problem comes from the fact that the AudioSystem callback indicating that the media server is active again is ignored if it is received before the delayed message indicating media server death. This happens if another application or service running in the system server process makes a request to the AudioSystem in the interval between the death of the media server and the reception of the corresponding delayed message. The fix consists in resetting mMediaServerOk flags immediately when the death callback is received and not when the delayed message is received. --- media/java/android/media/AudioService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index f4c458691ec82..d90871ea20180 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -178,12 +178,14 @@ public class AudioService extends IAudioService.Stub { if (mMediaServerOk) { sendMsg(mAudioHandler, MSG_MEDIA_SERVER_DIED, SHARED_MSG, SENDMSG_NOOP, 0, 0, null, 1500); + mMediaServerOk = false; } break; case AudioSystem.AUDIO_STATUS_OK: if (!mMediaServerOk) { sendMsg(mAudioHandler, MSG_MEDIA_SERVER_STARTED, SHARED_MSG, SENDMSG_NOOP, 0, 0, null, 0); + mMediaServerOk = true; } break; default: @@ -1282,10 +1284,13 @@ public class AudioService extends IAudioService.Stub { break; case MSG_MEDIA_SERVER_DIED: - Log.e(TAG, "Media server died."); // Force creation of new IAudioflinger interface - mMediaServerOk = false; - AudioSystem.isMusicActive(); + if (!mMediaServerOk) { + Log.e(TAG, "Media server died."); + AudioSystem.isMusicActive(); + sendMsg(mAudioHandler, MSG_MEDIA_SERVER_DIED, SHARED_MSG, SENDMSG_NOOP, 0, 0, + null, 500); + } break; case MSG_MEDIA_SERVER_STARTED: @@ -1323,8 +1328,6 @@ public class AudioService extends IAudioService.Stub { // Restore ringer mode setRingerModeInt(getRingerMode(), false); - - mMediaServerOk = true; break; case MSG_PLAY_SOUND_EFFECT: