【问题标题】:eglCreateWindowSurface() can only be called with an instance of Surface, SurfaceView, SurfaceTexture or SurfaceHoldereglCreateWindowSurface() 只能使用 Surface、SurfaceView、SurfaceTexture 或 SurfaceHolder 的实例调用
【发布时间】:2021-05-17 00:24:49
【问题描述】:

我正在使用 RecordableSurfaceView https://github.com/spaceLenny/recordablesurfaceview/blob/master/recordablesurfaceview/src/main/java/com/uncorkedstudios/android/view/recordablesurfaceview/RecordableSurfaceView.java

对于 android 6,(api 23)我收到此错误。有没有办法解决这个问题?

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

潜在的代码段。

 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);

【问题讨论】:

    标签: android opengl-es opengl-es-2.0 surfaceview


    【解决方案1】:

    为此 mEGLSurface 写一个空检查并完成 (mEGLSurface != null)

    【讨论】:

      【解决方案2】:

      RecordableSurfaceView 的代码sn-p 中,第二次调用eglCreateWindowSurface 传入一个mSurface 变量,该变量在doSetup 中通过以下方式初始化:

      mSurface = MediaCodec.createPersistentInputSurface();
      

      我猜你的编解码器不支持这个函数并且它以某种方式返回 null,这导致了你看到的异常。或者它可能被多个编解码器或记录器实例使用?

      我能找到的关于 SO 的唯一其他一些相关的问题是:MediaCodec's Persistent Input Surface unsupported by Camera2 Session?

      您能否至少从堆栈跟踪中澄清它在库中崩溃的位置?换句话说,来自eglCreateWindowSurface的哪个调用?

      【讨论】:

        猜你喜欢
        • 2012-05-24
        • 2015-02-19
        • 2017-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-04
        • 2012-10-19
        相关资源
        最近更新 更多