Merge changes I54dda008,Id06cb476
* changes: Fix exception message Fix JNI usage bugs.
This commit is contained in:
committed by
Android (Google) Code Review
commit
a3cd95f4a7
@@ -416,11 +416,13 @@ static void ImageReader_init(JNIEnv* env, jobject thiz, jobject weakThiz, jint w
|
||||
if (res != OK) {
|
||||
jniThrowExceptionFmt(env, "java/lang/IllegalStateException",
|
||||
"Failed to set buffer consumer default format 0x%x", nativeFormat);
|
||||
return;
|
||||
}
|
||||
res = bufferConsumer->setDefaultBufferDataSpace(nativeDataspace);
|
||||
if (res != OK) {
|
||||
jniThrowExceptionFmt(env, "java/lang/IllegalStateException",
|
||||
"Failed to set buffer consumer default dataSpace 0x%x", nativeDataspace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,7 +706,7 @@ static void Image_getLockedImage(JNIEnv* env, jobject thiz, LockedImage *image)
|
||||
// and we don't set them here.
|
||||
}
|
||||
|
||||
static void Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
|
||||
static bool Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
|
||||
int32_t writerFormat, uint8_t **base, uint32_t *size, int *pixelStride, int *rowStride) {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
@@ -713,7 +715,9 @@ static void Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
|
||||
if (res != OK) {
|
||||
jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException",
|
||||
"Pixel format: 0x%x is unsupported", buffer->flexFormat);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz,
|
||||
@@ -756,8 +760,10 @@ static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz,
|
||||
}
|
||||
// Create all SurfacePlanes
|
||||
for (int i = 0; i < numPlanes; i++) {
|
||||
Image_getLockedImageInfo(env, &lockedImg, i, halReaderFormat,
|
||||
&pData, &dataSize, &pixelStride, &rowStride);
|
||||
if (!Image_getLockedImageInfo(env, &lockedImg, i, halReaderFormat,
|
||||
&pData, &dataSize, &pixelStride, &rowStride)) {
|
||||
return NULL;
|
||||
}
|
||||
byteBuffer = env->NewDirectByteBuffer(pData, dataSize);
|
||||
if ((byteBuffer == NULL) && (env->ExceptionCheck() == false)) {
|
||||
jniThrowException(env, "java/lang/IllegalStateException",
|
||||
|
||||
@@ -777,6 +777,7 @@ static void Image_unlockIfLocked(JNIEnv* env, jobject thiz) {
|
||||
status_t res = buffer->unlock();
|
||||
if (res != OK) {
|
||||
jniThrowRuntimeException(env, "unlock buffer failed");
|
||||
return;
|
||||
}
|
||||
ALOGV("Successfully unlocked the image");
|
||||
}
|
||||
@@ -872,7 +873,7 @@ static void Image_getLockedImage(JNIEnv* env, jobject thiz, LockedImage *image)
|
||||
// and we don't set them here.
|
||||
}
|
||||
|
||||
static void Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
|
||||
static bool Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
|
||||
int32_t writerFormat, uint8_t **base, uint32_t *size, int *pixelStride, int *rowStride) {
|
||||
ALOGV("%s", __FUNCTION__);
|
||||
|
||||
@@ -880,8 +881,10 @@ static void Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
|
||||
pixelStride, rowStride);
|
||||
if (res != OK) {
|
||||
jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException",
|
||||
"Pixel format: 0x%x is unsupported", buffer->flexFormat);
|
||||
"Pixel format: 0x%x is unsupported", writerFormat);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz,
|
||||
@@ -920,8 +923,10 @@ static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz,
|
||||
PublicFormat publicWriterFormat = static_cast<PublicFormat>(writerFormat);
|
||||
writerFormat = mapPublicFormatToHalFormat(publicWriterFormat);
|
||||
for (int i = 0; i < numPlanes; i++) {
|
||||
Image_getLockedImageInfo(env, &lockedImg, i, writerFormat,
|
||||
&pData, &dataSize, &pixelStride, &rowStride);
|
||||
if (!Image_getLockedImageInfo(env, &lockedImg, i, writerFormat,
|
||||
&pData, &dataSize, &pixelStride, &rowStride)) {
|
||||
return NULL;
|
||||
}
|
||||
byteBuffer = env->NewDirectByteBuffer(pData, dataSize);
|
||||
if ((byteBuffer == NULL) && (env->ExceptionCheck() == false)) {
|
||||
jniThrowException(env, "java/lang/IllegalStateException",
|
||||
|
||||
Reference in New Issue
Block a user