mediaserver 异常挂掉引起的一个BUG

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 了。

发布了40 篇原创文章 · 获赞 11 · 访问量 12万+
展开阅读全文

安卓源码编译后 模拟器启动不起来

05-20

安卓源码中在libcore,以及frameworks , external目录下添加了一些log信息 编译后的system.img镜像, 模拟器运行不起来 log不断打印如下信息: D/AndroidRuntime( 855): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<< D/AndroidRuntime( 855): CheckJNI is ON I/SamplingProfilerIntegration( 855): Profiling disabled. I/dalvikvm( 855): threadid=1: stack overflow on call to Ljava/util/GregorianCalendar;.fullFieldsCalc:VJII I/dalvikvm( 855): method requires 100+20+28=148 bytes, fp is 0x4615f380 (128 left) I/dalvikvm( 855): expanding stack end (0x4615f300 to 0x4615f000) I/dalvikvm( 855): Shrank stack (to 0x4615f300, curFrame is 0x4615f670) D/AndroidRuntime( 855): Shutting down VM W/dalvikvm( 855): threadid=1: thread exiting with uncaught exception (group=0x409961f8) I/ServiceManager( 30): service 'media.audio_flinger' died I/ServiceManager( 30): service 'media.player' died I/ServiceManager( 30): service 'media.camera' died I/ServiceManager( 30): service 'media.audio_policy' died I/Netd ( 860): Netd 1.0 starting E/Netd ( 860): Unable to bind netlink socket: No such file or directory E/Netd ( 860): Unable to open quota2 logging socket I/ ( 859): ServiceManager: 0xf958 I/AudioFlinger( 859): Loaded primary audio interface from LEGACY Audio HW HAL (audio) I/AudioFlinger( 859): Using 'LEGACY Audio HW HAL' (audio.primary) as the primary audio interface D/AudioHardwareInterface( 859): setMode(NORMAL) I/CameraService( 859): CameraService started (pid=859) D/EmulatedCamera_QemuClient( 859): Emulated camera list: D/EmulatedCamera_FakeCamera( 859): Initialize: Fake camera is facing back V/EmulatedCamera_Factory( 859): 1 cameras are being emulated. Fake camera ID is 0 I/AudioFlinger( 859): AudioFlinger's thread 0x10f50 ready to run W/AudioFlinger( 859): Thread AudioOut_1 cannot connect to the power manager service I/AudioPolicyService( 859): Loaded audio policy from LEGACY Audio Policy HAL (audio_policy) 问答

安卓录像问题。报错Media server died.

09-28

public class MainActivity extends Activity { MediaRecorder recorder= null; Button startButton = null; Button endtButton = null; SurfaceView face = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startButton=(Button) findViewById(R.id.end); endtButton= (Button) findViewById(R.id.start); face= (SurfaceView) findViewById(R.id.surfaceView); face.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); face.getHolder().setFixedSize(176, 144); face.getHolder().setKeepScreenOn(true); startButton.setOnClickListener(ButtonClickDo); endtButton.setOnClickListener(ButtonClickDo); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public void startRecord() throws Throwable, IOException{ File f = new File( Environment.getExternalStorageDirectory() ,System.currentTimeMillis()+".3gp"); recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setVideoSize(320, 240); recorder.setVideoFrameRate(5); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB); recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); recorder.setOutputFile(f.getAbsolutePath()); recorder.setPreviewDisplay(face.getHolder().getSurface()); System.out.println("路径"+ f.getAbsolutePath()); recorder.prepare(); recorder.start(); } public void stopRecord(){ if(recorder!=null){ recorder.stop(); recorder.release(); recorder=null; } } private OnClickListener ButtonClickDo = new OnClickListener() { @Override public void onClick(View v) { Integer id = v.getId(); System.out.println("id为:"+ id +"结果" +(endtButton.getId()==id)); if(endtButton.getId()==id){ try { startRecord(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Throwable e) { // TODO Auto-generated catch block e.printStackTrace(); } } else{ stopRecord(); } } }; } 这段代码可以正常的录像, 发到手机内存里 。但是我把 recorder.setPreviewDisplay(face.getHolder().getSurface()); 这句话给注释掉就报 Media server died. 。拍出来的东西只有23KB 怎么拍都只有23KB 不能播放 说文件损坏, 请问是怎么回事。 我想达到 录像 但不显示录像的画面。 怎么操作 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览