在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源码下编译的,各位遇到过这种问题么,请指点迷津

解决方案 »

  1.   

    你好,可以麻烦告诉我你的Q吗?交流下native surface的问题
      

  2.   

    貌似是分辨率问题,不太懂,同求答案,你可以到一些专门的android技术论坛去看看,www.connectionwe.com,推荐一个
      

  3.   

    没具体搞过surface ,关注一下 。
      

  4.   

    给下源代码吧
    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就可以了,但是这样一直有问题。不知道还有人关注这个问题没
      

  5.   

    因为 mIsurface是私有的,只有friend类才有权访问,包括 mediaplayer.