android - 致命信号11(SIGSEGV)在0x00000010(代码= 1)错误

时间:2015-02-23 21:17:10

标签: android camera fatal-error sigsegv

我正在开发一个视频录制应用程序。按Home键,我试图再次运行它。但是,有时我没有收到错误,但最终我收到错误...我不知道是什么问题。请帮帮我。

公共类CameraActivity2扩展了ActionBarActivity {

private boolean isRecording = false;

private Camera mCamera = null;
private MediaRecorder mMediaRecorder = null;

private ImageView captureButton = null;

private SurfaceView mPreview=null;
private SurfaceHolder mHolder=null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_activity2);

    Log.d("myTag","onCreate//getCameraInstance");

    mPreview = (SurfaceView) findViewById(R.id.camera_preview);

    mHolder = mPreview.getHolder();
    mHolder.addCallback(surfaceListener);

    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);



    captureButton = (ImageView) findViewById(R.id.record);

    captureButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isRecording) {
                Log.d("myTag","Click");
                mMediaRecorder.stop();
                MediaManager.releaseMediaRecorder(mMediaRecorder, mCamera);

                mCamera.lock();

                captureButton
                        .setImageResource(R.drawable.device_access_camera);

                isRecording = false;
            } else {
                if (prepareVideoRecorder()) {
                    mMediaRecorder.start();
                    captureButton.setImageResource(R.drawable.av_stop);
                    isRecording = true;
                } else {
                    MediaManager.releaseMediaRecorder(mMediaRecorder,
                            mCamera);
                }
            }
        }
    });
}


@Override
protected void onPause() {
    Log.d("myTag","------------PAUSE------------");
    super.onPause();
    MediaManager.releaseMediaRecorder(mMediaRecorder, mCamera);
    CameraManager.releaseCamera(mCamera);
    captureButton
            .setImageResource(R.drawable.device_access_camera);
    isRecording = false;
}


private SurfaceHolder.Callback surfaceListener = new SurfaceHolder.Callback() {

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        Log.i("camera", "Camera Release!");
        try {
            mCamera.release();
            mCamera = null;
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        Log.i("camera", "Camera Open");
        try {
            mCamera = Camera.open();
            mCamera.setPreviewDisplay(holder);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        // TODO Auto-generated method stub
        Log.i("camera", "Camera Preview");
        Camera.Parameters parameters = mCamera.getParameters();
        parameters.setPreviewSize(width, height);
        mCamera.startPreview();
    }
};

private boolean prepareVideoRecorder() {

    CameraManager.releaseCamera(mCamera);

    mCamera = CameraManager.getCameraInstance(mCamera);
    mMediaRecorder = new MediaRecorder();

    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);

    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    mMediaRecorder.setProfile(CamcorderProfile
            .get(CamcorderProfile.QUALITY_720P));

    mMediaRecorder.setOutputFile(FileManager.getOutputMediaFile()
            .toString());

    mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());

    try {
        mMediaRecorder.prepare();
    } catch (IllegalStateException e) {
        MediaManager.releaseMediaRecorder(mMediaRecorder, mCamera);
        return false;
    } catch (IOException e) {
        MediaManager.releaseMediaRecorder(mMediaRecorder, mCamera);
        return false;
    }
    return true;
}

}

这是我的LogCat。

02-24 06:00:37.774  23236-23236/com.example.ohhye.packagemovie I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
    OpenGL ES Shader Compiler Version: E031.24.00.08
    Build Date: 02/20/14 Thu
    Local Branch: AU200_patches_ms_memleak_libsc_profiler
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
02-24 06:00:37.804  23236-23236/com.example.ohhye.packagemovie D/OpenGLRenderer﹕ Enabling debug mode 0
02-24 06:00:44.124  23236-23236/com.example.ohhye.packagemovie I/PersonaManager﹕ getPersonaService() name persona_policy
02-24 06:00:44.144  23236-23236/com.example.ohhye.packagemovie D/skia﹕ GFXPNG PNG bitmap created width:48 height:48 bitmap id is 287
02-24 06:00:44.144  23236-23236/com.example.ohhye.packagemovie D/myTag﹕ onCreate//getCameraInstance
02-24 06:00:44.174  23236-23236/com.example.ohhye.packagemovie I/camera﹕ Camera Open
02-24 06:00:44.374  23236-23236/com.example.ohhye.packagemovie I/camera﹕ Camera Preview
02-24 06:00:44.854  23236-23236/com.example.ohhye.packagemovie I/Choreographer﹕ Skipped 40 frames!  The application may be doing too much work on its main thread.
02-24 06:00:51.584  23236-23236/com.example.ohhye.packagemovie I/MediaRecorderJNI﹕ prepare: surface=0x72ee3498
02-24 06:00:53.474  23236-23236/com.example.ohhye.packagemovie D/skia﹕ GFXPNG PNG bitmap created width:48 height:48 bitmap id is 288
02-24 06:00:53.474  23236-23236/com.example.ohhye.packagemovie I/Choreographer﹕ Skipped 155 frames!  The application may be doing too much work on its main thread.
02-24 06:00:55.144  23236-23236/com.example.ohhye.packagemovie D/myTag﹕ Click
02-24 06:00:57.904  23236-23236/com.example.ohhye.packagemovie D/myTag﹕ ------------PAUSE------------
02-24 06:00:57.904  23236-23236/com.example.ohhye.packagemovie A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x00000010 (code=1), thread 23236 (ye.packagemovie)

0 个答案:

没有答案