Loading core/java/android/hardware/camera2/impl/CameraMetadataNative.java +30 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import android.util.Range; import android.util.Size; import dalvik.annotation.optimization.FastNative; import dalvik.system.VMRuntime; import java.io.IOException; import java.nio.ByteBuffer; Loading Loading @@ -351,6 +352,7 @@ public class CameraMetadataNative implements Parcelable { if (mMetadataPtr == 0) { throw new OutOfMemoryError("Failed to allocate native CameraMetadata"); } updateNativeAllocation(); } /** Loading @@ -362,6 +364,7 @@ public class CameraMetadataNative implements Parcelable { if (mMetadataPtr == 0) { throw new OutOfMemoryError("Failed to allocate native CameraMetadata"); } updateNativeAllocation(); } /** Loading Loading @@ -443,6 +446,7 @@ public class CameraMetadataNative implements Parcelable { public void readFromParcel(Parcel in) { nativeReadFromParcel(in, mMetadataPtr); updateNativeAllocation(); } /** Loading Loading @@ -533,6 +537,11 @@ public class CameraMetadataNative implements Parcelable { // Delete native pointer, but does not clear it nativeClose(mMetadataPtr); mMetadataPtr = 0; if (mBufferSize > 0) { VMRuntime.getRuntime().registerNativeFree(mBufferSize); } mBufferSize = 0; } private <T> T getBase(CameraCharacteristics.Key<T> key) { Loading Loading @@ -1645,9 +1654,26 @@ public class CameraMetadataNative implements Parcelable { return true; } private void updateNativeAllocation() { long currentBufferSize = nativeGetBufferSize(mMetadataPtr); if (currentBufferSize != mBufferSize) { if (mBufferSize > 0) { VMRuntime.getRuntime().registerNativeFree(mBufferSize); } mBufferSize = currentBufferSize; if (mBufferSize > 0) { VMRuntime.getRuntime().registerNativeAllocation(mBufferSize); } } } private int mCameraId = -1; private boolean mHasMandatoryConcurrentStreams = false; private Size mDisplaySize = new Size(0, 0); private long mBufferSize = 0; /** * Set the current camera Id. Loading Loading @@ -1705,6 +1731,8 @@ public class CameraMetadataNative implements Parcelable { private static synchronized native boolean nativeIsEmpty(long ptr); @FastNative private static synchronized native int nativeGetEntryCount(long ptr); @FastNative private static synchronized native long nativeGetBufferSize(long ptr); @UnsupportedAppUsage @FastNative Loading Loading @@ -1744,6 +1772,8 @@ public class CameraMetadataNative implements Parcelable { mCameraId = other.mCameraId; mHasMandatoryConcurrentStreams = other.mHasMandatoryConcurrentStreams; mDisplaySize = other.mDisplaySize; updateNativeAllocation(); other.updateNativeAllocation(); } /** Loading core/jni/android_hardware_camera2_CameraMetadata.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,16 @@ static jint CameraMetadata_getEntryCount(JNIEnv *env, jclass thiz, jlong ptr) { return metadata->entryCount(); } static jlong CameraMetadata_getBufferSize(JNIEnv *env, jclass thiz, jlong ptr) { ALOGV("%s", __FUNCTION__); CameraMetadata* metadata = CameraMetadata_getPointerThrow(env, ptr); if (metadata == NULL) return 0; return metadata->bufferSize(); } // idempotent. calling more than once has no effect. static void CameraMetadata_close(JNIEnv *env, jclass thiz, jlong ptr) { ALOGV("%s", __FUNCTION__); Loading Loading @@ -552,6 +562,9 @@ static const JNINativeMethod gCameraMetadataMethods[] = { { "nativeGetEntryCount", "(J)I", (void*)CameraMetadata_getEntryCount }, { "nativeGetBufferSize", "(J)J", (void*)CameraMetadata_getBufferSize }, { "nativeClose", "(J)V", (void*)CameraMetadata_close }, Loading Loading
core/java/android/hardware/camera2/impl/CameraMetadataNative.java +30 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import android.util.Range; import android.util.Size; import dalvik.annotation.optimization.FastNative; import dalvik.system.VMRuntime; import java.io.IOException; import java.nio.ByteBuffer; Loading Loading @@ -351,6 +352,7 @@ public class CameraMetadataNative implements Parcelable { if (mMetadataPtr == 0) { throw new OutOfMemoryError("Failed to allocate native CameraMetadata"); } updateNativeAllocation(); } /** Loading @@ -362,6 +364,7 @@ public class CameraMetadataNative implements Parcelable { if (mMetadataPtr == 0) { throw new OutOfMemoryError("Failed to allocate native CameraMetadata"); } updateNativeAllocation(); } /** Loading Loading @@ -443,6 +446,7 @@ public class CameraMetadataNative implements Parcelable { public void readFromParcel(Parcel in) { nativeReadFromParcel(in, mMetadataPtr); updateNativeAllocation(); } /** Loading Loading @@ -533,6 +537,11 @@ public class CameraMetadataNative implements Parcelable { // Delete native pointer, but does not clear it nativeClose(mMetadataPtr); mMetadataPtr = 0; if (mBufferSize > 0) { VMRuntime.getRuntime().registerNativeFree(mBufferSize); } mBufferSize = 0; } private <T> T getBase(CameraCharacteristics.Key<T> key) { Loading Loading @@ -1645,9 +1654,26 @@ public class CameraMetadataNative implements Parcelable { return true; } private void updateNativeAllocation() { long currentBufferSize = nativeGetBufferSize(mMetadataPtr); if (currentBufferSize != mBufferSize) { if (mBufferSize > 0) { VMRuntime.getRuntime().registerNativeFree(mBufferSize); } mBufferSize = currentBufferSize; if (mBufferSize > 0) { VMRuntime.getRuntime().registerNativeAllocation(mBufferSize); } } } private int mCameraId = -1; private boolean mHasMandatoryConcurrentStreams = false; private Size mDisplaySize = new Size(0, 0); private long mBufferSize = 0; /** * Set the current camera Id. Loading Loading @@ -1705,6 +1731,8 @@ public class CameraMetadataNative implements Parcelable { private static synchronized native boolean nativeIsEmpty(long ptr); @FastNative private static synchronized native int nativeGetEntryCount(long ptr); @FastNative private static synchronized native long nativeGetBufferSize(long ptr); @UnsupportedAppUsage @FastNative Loading Loading @@ -1744,6 +1772,8 @@ public class CameraMetadataNative implements Parcelable { mCameraId = other.mCameraId; mHasMandatoryConcurrentStreams = other.mHasMandatoryConcurrentStreams; mDisplaySize = other.mDisplaySize; updateNativeAllocation(); other.updateNativeAllocation(); } /** Loading
core/jni/android_hardware_camera2_CameraMetadata.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -249,6 +249,16 @@ static jint CameraMetadata_getEntryCount(JNIEnv *env, jclass thiz, jlong ptr) { return metadata->entryCount(); } static jlong CameraMetadata_getBufferSize(JNIEnv *env, jclass thiz, jlong ptr) { ALOGV("%s", __FUNCTION__); CameraMetadata* metadata = CameraMetadata_getPointerThrow(env, ptr); if (metadata == NULL) return 0; return metadata->bufferSize(); } // idempotent. calling more than once has no effect. static void CameraMetadata_close(JNIEnv *env, jclass thiz, jlong ptr) { ALOGV("%s", __FUNCTION__); Loading Loading @@ -552,6 +562,9 @@ static const JNINativeMethod gCameraMetadataMethods[] = { { "nativeGetEntryCount", "(J)I", (void*)CameraMetadata_getEntryCount }, { "nativeGetBufferSize", "(J)J", (void*)CameraMetadata_getBufferSize }, { "nativeClose", "(J)V", (void*)CameraMetadata_close }, Loading