[Android] more additions to the camera activity

This commit is contained in:
ToadKing 2013-11-17 16:45:46 -05:00
parent ccb81396e6
commit b22842ede2

View File

@ -10,7 +10,9 @@ import android.os.Build;
public final class RetroActivity extends NativeActivity public final class RetroActivity extends NativeActivity
{ {
Camera mCamera; private Camera mCamera;
private long lastTimestamp = 0;
private SurfaceTexture texture;
public void onCameraStart() public void onCameraStart()
{ {
@ -27,6 +29,29 @@ public final class RetroActivity extends NativeActivity
mCamera = Camera.open(); mCamera = Camera.open();
} }
@SuppressLint("NewApi")
public boolean onCameraPoll()
{
boolean ret;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
{
long newTimestamp = texture.getTimestamp();
if (newTimestamp != lastTimestamp)
{
lastTimestamp = newTimestamp;
ret = true;
}
else
{
ret = false;
}
}
else
ret = true;
return ret;
}
public void onCameraFree() public void onCameraFree()
{ {
mCamera.release(); mCamera.release();
@ -37,7 +62,10 @@ public final class RetroActivity extends NativeActivity
public void onCameraSetTexture(int gl_texid) throws IOException public void onCameraSetTexture(int gl_texid) throws IOException
{ {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mCamera.setPreviewTexture(new SurfaceTexture(gl_texid)); {
texture = new SurfaceTexture(gl_texid);
mCamera.setPreviewTexture(texture);
}
else else
mCamera.setPreviewDisplay(null); mCamera.setPreviewDisplay(null);
} }