Android MediaCodec:eglSwapBuffers:EGL错误:0x300d

时间:2015-05-06 00:18:38

标签: android opengl-es-2.0 mediacodec egl mediamuxer

所以问题只发生在我第二次尝试录制时。这意味着我第一次运行MediaCodecs和Muxer时,一切都在运行。但现在我希望应用程序更加稳定。

帮助确定未被拆除和正确设置的内容。

基本上在第二次运行时,一切设置都很好,但是当' Renderer.drawFrame'致电GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);我收到错误:I/Adreno﹕ Native window GetBuffer failed

当调用GLES20.glFlush();时,错误为:I/Adreno﹕ Failed to acquire a surface

当我尝试交换缓冲区时,它始终位于eglSwapBuffers: EGL error: 0x300d之前。所以从第一次运行起就没有清理过。

清理代码:

    public void releaseCapture(){
    if (audioCodec != null){
        audioCodec.stop();
        audioCodec = null;
    }
    if (videoCodec != null){
        videoCodec.stop();
        videoCodec = null;
    }
    if (mediaMux != null){
        mediaMux.release();
        mediaMux = null;
    }
    if ( releaseAll ) {
        releaseAll = false;
        //releaseSurfaceTexture();
        mEGLWrapper.destroySurface();
    }
}

MyMediaCodec.stop()

public void stop(){
    if (codec == null) return; 
    if (!isAudioCodec) {
        videoCodecInputSurface.release();
    }
    codecPrimed=false;
    codec.stop();
    codec.release();
    codec = null;
    codecManager.stopMuxer(isAudioCodec);
}

MyMediaMuxer.stop()

    public void stopMuxer(boolean isAudio){
    if (mediaMux == null) return;
    if (isAudio){
        audioActive = false;
    } else {
        videoActive = false;
    }
    if (!(audioActive||videoActive)){
        Log.d(TAG, "Stopping Muxer now. audio frame count = " + audioFrameCount +
                "; video frame count = " + videoFrameCount);
        videoHandler.postDelayed(new Runnable(){

            @Override
            public void run() {
                if (mediaMux!=null) mediaMux.stop();
                // set up for next run
                releaseCapture();
            }

        },frame_delay);
    }
}

mEGLWrapper.destroySurface();

public void destroySurface(){
    EGL14.eglDestroySurface(mEGLDisplay,mEGLSurface);
    checkEglError("eglDestroySurace");
}

错误日志

05-05 17:51:43.072  27756-27913/com.harmonicprocesses.penelopefree 

E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
05-05 17:51:43.085  27756-27918/com.harmonicprocesses.penelopefree I/OMXClient﹕ Using client-side OMX mux.
05-05 17:51:43.470  27756-27756/com.harmonicprocesses.penelopefree D/penny.cam.MyMediaCodec﹕ Camera profile: Frame Rate = 30; Bit Rate = 42000000
05-05 17:51:43.470  27756-27756/com.harmonicprocesses.penelopefree D/penny.cam.MyMediaCodec﹕ ; Heighth = 2160; Width = 3840
05-05 17:51:43.472  27756-27918/com.harmonicprocesses.penelopefree E/ACodec﹕ [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -1010
05-05 17:51:43.474  27756-27918/com.harmonicprocesses.penelopefree W/ACodec﹕ do not know color format 0x7fa30c04 = 2141391876
05-05 17:51:43.475  27756-27918/com.harmonicprocesses.penelopefree W/ACodec﹕ do not know color format 0x7f000789 = 2130708361
05-05 17:51:43.478  27756-27918/com.harmonicprocesses.penelopefree I/ACodec﹕ setupVideoEncoder succeeded
05-05 17:51:43.478  27756-27918/com.harmonicprocesses.penelopefree W/ACodec﹕ do not know color format 0x7f000789 = 2130708361
05-05 17:52:57.317  27756-27784/com.harmonicprocesses.penelopefree I/Adreno﹕ Native window GetBuffer failed
05-05 17:55:41.518  27756-27784/com.harmonicprocesses.penelopefree I/Adreno﹕ Failed to acquire a surface
05-05 17:56:24.246  27756-27791/com.harmonicprocesses.penelopefree V/com.hpp.MyMediaMux﹕ Trying to write data before muxer started, isAudioSample = true
05-05 18:04:55.189  27756-27784/com.harmonicprocesses.penelopefree D/io.hpp.MyGLSurfaceView18﹕ eglSwapBuffers: EGL error: 0x300d
05-05 18:04:55.189  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ java.lang.Exception
05-05 18:04:55.189  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.hpp.openGL.MyEGLWrapper.checkEglError(MyEGLWrapper.java:443)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.hpp.openGL.MyEGLWrapper.swapBuffers(MyEGLWrapper.java:314)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager.drawFrame(CaptureManager.java:478)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager.drawFrameOnInputSurface(CaptureManager.java:463)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager.videoCaptureLoop(CaptureManager.java:335)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager$5.run(CaptureManager.java:318)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
05-05 18:04:55.190  27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

1 个答案:

答案 0 :(得分:0)

甜蜜,我在发布后很快得到了它。一个EGL14.eglDestroySurface(mEGLDisplay,mEGLSurface);没有像我假设的那样将mEGLSurface设置为EGL14.EGL_NO_SURFACE。你不会知道它,因为我没有发布它,但MyEGLWrapper.makeCurrent()检查这个:

    public void makeCurrent(boolean toScreen, Surface surface) {
    if (toScreen) { //as opposed to toEncoder
        makeScreenSurfaceCurrent();
        return;
    } 
    if (mEGLSurface.equals(EGL14.EGL_NO_SURFACE)){

        mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], surface,
                surfaceAttribs, 0);
        checkEglError("eglCreateWindowSurface");
    }
    EGL14.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
    checkEglError("eglMakeCurrent");
}

和两个,releaseAll被设置为false所以mEGLSurface甚至没有被破坏......

感谢您的光临。