简体   繁体   中英

eglCreateWindowSurface() can only be called with an instance of Surface, SurfaceView, SurfaceTexture or SurfaceHolder

I am using RecordableSurfaceView https://github.com/spaceLenny/recordablesurfaceview/blob/master/recordablesurfaceview/src/main/java/com/uncorkedstudios/android/view/recordablesurfaceview/RecordableSurfaceView.java

For android 6, (api 23) I get this error. Is there a way to fix this?

eglCreateWindowSurface() can only be called with an instance of Surface, SurfaceView, SurfaceTexture or SurfaceHolder at the moment, this will be fixed later.
.RecordableSurfaceView

The potential code segment.

 mEGLSurface = EGL14
                .eglCreateWindowSurface(mEGLDisplay, eglConfig, RecordableSurfaceView.this,
                        surfaceAttribs, 0);
        EGL14.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);

        // guarantee to only report surface as created once GL context
        // associated with the surface has been created, and call on the GL thread
        // NOT the main thread but BEFORE the codec surface is attached to the GL context
        if (mRendererCallbacksWeakReference != null
                && mRendererCallbacksWeakReference.get() != null) {

            mRendererCallbacksWeakReference.get().onSurfaceCreated();

        }

        mEGLSurfaceMedia = EGL14
                .eglCreateWindowSurface(mEGLDisplay, eglConfig, mSurface,
                        surfaceAttribs, 0);

        GLES20.glClearColor(0.1f, 0.1f, 0.1f, 1.0f);

write a null check for this mEGLSurface and done (mEGLSurface != null)

In the code snippet of RecordableSurfaceView the second call to eglCreateWindowSurface passes in a mSurface variable which is initialized in doSetup via:

mSurface = MediaCodec.createPersistentInputSurface();

I would guess that your codec doesn't support this function and it's somehow returning null, which is causing the exception you see. Or perhaps it's being used by more than one codec or recorder instance?

The only other somewhat related question on SO I could find is: MediaCodec's Persistent Input Surface unsupported by Camera2 Session?

Can you at least clarify from the stack trace where in the library it's crashing? In other words, from which call of eglCreateWindowSurface ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM