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

Commit 89e74ba1 authored by Eric Laurent's avatar Eric Laurent
Browse files

Fix Issue 2158631: AudioService: volume control sometimes not restored after...

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.
parent a33e3f79
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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;
                    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: