在BigFlake示例之后,有一条注释声明:
// Acquire a new frame of input, and render it to the Surface. If we had a
// GLSurfaceView we could switch EGL contexts and call drawImage() a second
// time to render it on screen. The texture can be shared between contexts by
// passing the GLSurfaceView's EGLContext as eglCreateContext()'s share_context
// argument.
我使用EGL14.getCurrentContext()
查询当前上下文并将其传递给EGL14.eglCreateContext()
share_context参数,但是如何“切换EGL上下文”?
GLSurfaceView和MediaCodec.inputSurface有两个不同的曲面和两个不同的上下文,所以我假设您只是在每个集合上分别调用eglMakeCurrent()
,对吗?你需要eglDestroyContext()
还是eglDestroySurface()
?
添加了更新
谢谢Fadden,我想我发现了这个错误,而不是drawFrame,而是调用了drawImage,但是您不需要第二次更新图像,对吗?
现在,当在EOS设置好之后调用dequeueBuffer时,我得到了内存不足的错误dequeueBuffer。也许我是在录音停止后打电话给它的。谢谢你的帮助。
在EGLSurface中创建MyEGLWrapper.java
saveToScreenRenderState();
mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], mScreenEglContext,
contextAttribs, 0);
checkEglError("eglCreateContext");
// Create a window surface, and attach it to the Surface we received.
mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
surfaceAttribs, 0);
checkEglError("eglCreateWindowSurface");
...
private void saveToScreenRenderState() {
//System.arraycopy(mProjectionMatrix, 0, mSavedMatrix, 0, mProjectionMatrix.length);
mScreenEglDisplay = EGL14.eglGetCurrentDisplay();
mScreenEglDrawSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
mScreenEglReadSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_READ);
mScreenEglContext = EGL14.eglGetCurrentContext();
}
public void makeCurrent(boolean toScreen, Surface surface) {
if (toScreen) { //as opposed to toEncoder
makeScreenSurfaceCurrent();
return;
}
EGL14.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
checkEglError("eglMakeCurrent");
}
private void makeScreenSurfaceCurrent() {
EGL14.eglMakeCurrent(mScreenEglDisplay, mScreenEglDrawSurface,
mScreenEglReadSurface, mScreenEglContext);
checkEglError("eglMakeCurrent");
}
在CaptureManager.java中
private void drawFrameOnInputSurface() {
//draw a second time for inputSurface
mEGLWrapper.makeCurrent(false, videoCodec.videoCodecInputSurface);
drawFrame(false);
//ByteBuffer frame = mStManager.drawImage();
videoCodec.runQue(false); // clear que before posting should this be on this thread???
mEGLWrapper.setPresentationTime(mSt.getTimestamp(),!recordingStopped);
mEGLWrapper.swapBuffers(!recordingStopped);
videoHandler.post(new Runnable(){
@Override
public void run(){
videoCodec.updateFrame(!isRecording);
}
});
}
private void drawFrame(boolean updateImage){
mStManager.drawImage(updateImage);
mGLView.mRenderer.drawFrame();
}
在SurfaceTextureManager.java中
public ByteBuffer drawImage(boolean updateImage) {
// Latch the data.
if (updateImage){
mTextureRender.checkGlError("before updateTexImage");
mSurfaceTexture.updateTexImage();
}
return mTextureRender.drawFrame(mSurfaceTexture);
}
SurfaceTextureManager.java在mSurfaceTexture.updateTexImage();
上的错误
发布于 2013-10-31 14:55:54
https://stackoverflow.com/questions/19699651
复制相似问题