mediaserver 异常挂掉引起的一个BUG
具体问题:
由于CAMERA的问题,导致Mediaservice 挂掉,audioflinger, audiopolicyservice 也一起被杀掉了。KERNEL HIFI并没有关掉。
处理方法:
AudioService 中有注册audioflinger, audiopolicyservice DIE 掉的回调函数,
具体就是这个
private final AudioSystem.ErrorCallback mAudioSystemCallback = new AudioSystem.ErrorCallback() {
public void onError(int error) {
switch (error) {
case AudioSystem.AUDIO_STATUS_SERVER_DIED:
sendMsg(mAudioHandler, MSG_MEDIA_SERVER_DIED,
SENDMSG_NOOP, 0, 0, null, 0);
break;
default:
break;
}
}
};
在 AudioHandler 处理中,
case MSG_MEDIA_SERVER_DIED:
if (AudioSystem.checkAudioFlinger() != AudioSystem.AUDIO_STATUS_OK) {
Log.e(TAG, "Media server died.");
sendMsg(mAudioHandler, MSG_MEDIA_SERVER_DIED, SENDMSG_NOOP, 0, 0,
null, 500);
break;
}
Log.e(TAG, "Media server started.");
// indicate to audio HAL that we start the reconfiguration phase after a media
// server crash
// Note that we only execute this when the media server
// process restarts after a crash, not the first time it is started.
AudioSystem.setParameters("restarting=true");
readAndSetLowRamDevice();
首先是每隔500 MS 查询一次SERVICE是否已经重启OK了,如果OK了重新将上面的状态设置到底层去。在这个地方重新设置下HIFI 状态就OK 了。