Thank you for the quick response, fadden.
Building more on my previous message, I imagine something like the
following:
- GLSurfaceView that calls my native library for Render/input events
(like the san-angeles example).
- Camera preview object that also calls into the same native library.
Now, the GLSurfaceView is rendering on its' own thread at some
interval. Additionally, the Camera preview is being received on a
separate thread at some different interval. At some point, the Camera
preview data has to safely make the jump from the Camera preview
thread to the GLSurfaceView thread (or at least into a safe area for
the GLSurfaceView to access) so that it can safely be turned into an
OpenGL texture and rendered.
My question is about the last part. What is the "Android way" of
making that happen? Would you suggest using MonitorEnter/MonitorExit,
or perhaps pthread mutexes when this needs to happen? One idea that
comes to mind is having the native Camera Preview code first do the
conversion to a buffer, and then use a mutex to lock OpenGL while it
loads it as a texture, unlocking it when it is finished. Does this
seem like a good idea? Can you see any problems that might come with
this approach?
Thanks again for your help.