![](/img/trans.png)
[英]Android SDK] Error when loading the SDK: Error: Error parsing C:\Users\Atul Rai\android-sdks\system-images\android-22\
[英]USE ANativeWindow_lock return error -22 with android Gstreamer SDK
大家,
现在,我通过修改http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video这个项目来使用Android Gstreamer SDK来实现流式传输,并且我想在流式传输时捕获图像,因此我添加了一个JNI函数来渲染框架,这是下面的函数:
void gst_native_render_image(JNIEnv *env, jobject thiz, jobject surface){
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
if (!data)
return;
GST_DEBUG ("Releasing Native Window %p", data->native_window);
ANativeWindow_Buffer buffer;
//ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
render_window = ANativeWindow_fromSurface(env, surface);
ANativeWindow_acquire(render_window);
//ANativeWindow *window = data->native_window;
GST_DEBUG("Got window %p", render_window);
if(render_window > 0){
int width = ANativeWindow_getWidth(render_window);
int height = ANativeWindow_getHeight(render_window);
GST_DEBUG("Got window %d %d", width,height);
ANativeWindow_setBuffersGeometry(render_window, width, height, WINDOW_FORMAT_RGBA_8888);
memset((void*)&buffer,0,sizeof(buffer));
int lockResult = 0;
lockResult = ANativeWindow_lock(render_window, &buffer, NULL);
if (lockResult == 0) {
GST_DEBUG("GStreamer: ANativeWindow_locked");
memcpy(buffer.bits, g_buffer, 640*320);
ANativeWindow_unlockAndPost(render_window);
}
else{
GST_DEBUG("GStreamer: ANativeWindow_lock failed error %d",lockResult);
}
GST_DEBUG("Releasing window");
ANativeWindow_release(render_window);
(*env)->CallVoidMethod(env, thiz, surface_pixel_render_id); // call JAVA method to save the pixel data....oranhuang
}else {
GST_DEBUG("surface is null");
}
}
但是我总是通过ANativeWindow_lock()
得到返回错误-22。
还有什么我需要做的或以错误的方式使用ANativeWindow_lock()
吗????
因为ANativeWindow_lock()
只有很少的关于ANativeWindow_lock()
讨论, ANativeWindow_lock()
我不知道如何解决我的错误消息。
我遇到了类似的问题,这也花了我数千个小时。 但是,结果ANativeWindow_fromSurface
简单,这是ANativeWindow_fromSurface
的注释中的ANativeWindow_fromSurface
:
/*... This acquires a reference on the ANativeWindow that is returned; be sure to use ANativeWindow_release() ...*/
因此,窗口对象将锁定在ANativeWindow_fromSurface
。 不只是ANativeWindow_acquire
! 因此,答案是:你必须调用ANativeWindow_release
两次释放它,如果你已经叫ANativeWindow_acquire
锁定窗口前一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.