在java中获取surfaceview,然后将native surface传递给jni,之后lock surface进行绘制。绘制部分代码是这样的:lockSurface(....)
{
Surface::SurfaceInfo info;
Region dirtyRegion; dirtyRegion.set(Rect(0x3FFF,0x3FFF));
mSurface->lock(&info,&diretyRegion,true);//mSurface为传递过来的native surface
.....
获得info.bits然后将图像数据memcpy到其中;
}unlockSurface(..)
{
mSurface->unlockAndPost();
}但是现在红色行,lock出错。ddms中错误为:
surface requtetBuffer returneda buffer with a null handle
getBufferLocked failed(Out of memeory)
dequeueBuffer failed(out of memeory)
unlockAndPost failed, no locked buffer我是在Eclair源码下编译的,各位遇到过这种问题么,请指点迷津
{
Surface::SurfaceInfo info;
Region dirtyRegion; dirtyRegion.set(Rect(0x3FFF,0x3FFF));
mSurface->lock(&info,&diretyRegion,true);//mSurface为传递过来的native surface
.....
获得info.bits然后将图像数据memcpy到其中;
}unlockSurface(..)
{
mSurface->unlockAndPost();
}但是现在红色行,lock出错。ddms中错误为:
surface requtetBuffer returneda buffer with a null handle
getBufferLocked failed(Out of memeory)
dequeueBuffer failed(out of memeory)
unlockAndPost failed, no locked buffer我是在Eclair源码下编译的,各位遇到过这种问题么,请指点迷津
static int setVideoSurface(AndroidPlayer* mp, JNIEnv *env, jobject thiz) {
jobject surface = env->GetObjectField(thiz, fields.surface);
if (surface != NULL) {
const sp<Surface> native_surface = get_surface(env, surface);
return mp->_setVideoSurface(native_surface);
} else {
return mp->_setVideoSurface(NULL);
}
}
struct fields_t {
jfieldID context;
jfieldID surface;
jfieldID surface_native;
};
static fields_t fields;static sp<Surface> get_surface(JNIEnv* env, jobject clazz) {
sp<Surface> p = (Surface*)env->GetIntField(clazz, fields.surface_native);
return p;
}应用中直接将surface_native直接赋给C代码中的surface就可以了,但是这样一直有问题。不知道还有人关注这个问题没