title: USE ANativeWindow_lock return error -22 with android Gstreamer SDK
body: <p>everyone,</p>
  
  <p>now I am using Android Gstreamer SDK to implement streaming, by modifying <a href="http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video" rel="nofollow">http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video</a> this project, 
  and  I want to capture a image while streaming, so I add a JNI function to render a frame,
  Here is my function below:</p>
  
  <pre><code>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-&gt;native_window);
  
           ANativeWindow_Buffer buffer;
           //ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
           render_window = ANativeWindow_fromSurface(env, surface);
           ANativeWindow_acquire(render_window);
           //ANativeWindow *window = data-&gt;native_window;
           GST_DEBUG("Got window %p", render_window);
  
           if(render_window &gt; 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*)&amp;buffer,0,sizeof(buffer));
  
                   int lockResult = 0;
  
                   lockResult = ANativeWindow_lock(render_window, &amp;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)-&gt;CallVoidMethod(env, thiz, surface_pixel_render_id); // call JAVA method to save the pixel data....oranhuang
           }else {
                   GST_DEBUG("surface is null");
           }
  }
  </code></pre>
  
  <p>but I always get return error -22 with <code>ANativeWindow_lock()</code>.</p>
  
  <p>Is there anything else I need to do OR using <code>ANativeWindow_lock()</code> in the wrong way????</p>
  
  <p>'cause there are just few discusses with <code>ANativeWindow_lock()</code> on the line , 
  I don't know how to fix my error message..</p>