Android: some readability: redundant casts, deads stores, redundant control flow

This commit is contained in:
Sylvain Becker 2019-10-31 15:53:10 +01:00
parent fea3c8bdef
commit 303646a697
3 changed files with 6 additions and 11 deletions

View File

@ -1311,7 +1311,7 @@ void Android_JNI_SetActivityTitle(const char *title)
{
JNIEnv *env = Android_JNI_GetEnv();
jstring jtitle = (jstring)((*env)->NewStringUTF(env, title));
jstring jtitle = (*env)->NewStringUTF(env, title);
(*env)->CallStaticBooleanMethod(env, mActivityClass, midSetActivityTitle, jtitle);
(*env)->DeleteLocalRef(env, jtitle);
}
@ -1326,7 +1326,7 @@ void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
{
JNIEnv *env = Android_JNI_GetEnv();
jstring jhint = (jstring)((*env)->NewStringUTF(env, (hint ? hint : "")));
jstring jhint = (*env)->NewStringUTF(env, (hint ? hint : ""));
(*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint);
(*env)->DeleteLocalRef(env, jhint);
}
@ -1371,7 +1371,6 @@ static jobject captureBuffer = NULL;
int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec)
{
int audioformat;
int numBufferFrames;
jobject jbufobj = NULL;
jobject result;
int *resultElements;
@ -1476,7 +1475,6 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec)
audioBufferFormat = audioformat;
audioBuffer = jbufobj;
}
numBufferFrames = (*env)->GetArrayLength(env, (jarray)jbufobj);
if (!iscapture) {
isCopy = JNI_FALSE;
@ -1578,7 +1576,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen)
if (br > 0) {
jbyte *ptr = (*env)->GetByteArrayElements(env, (jbyteArray)captureBuffer, &isCopy);
SDL_memcpy(buffer, ptr, br);
(*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, (jbyte *)ptr, JNI_ABORT);
(*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, ptr, JNI_ABORT);
}
break;
case ENCODING_PCM_16BIT:
@ -1588,7 +1586,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen)
jshort *ptr = (*env)->GetShortArrayElements(env, (jshortArray)captureBuffer, &isCopy);
br *= sizeof(Sint16);
SDL_memcpy(buffer, ptr, br);
(*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, (jshort *)ptr, JNI_ABORT);
(*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, ptr, JNI_ABORT);
}
break;
case ENCODING_PCM_FLOAT:
@ -1598,7 +1596,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen)
jfloat *ptr = (*env)->GetFloatArrayElements(env, (jfloatArray)captureBuffer, &isCopy);
br *= sizeof(float);
SDL_memcpy(buffer, ptr, br);
(*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, (jfloat *)ptr, JNI_ABORT);
(*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, ptr, JNI_ABORT);
}
break;
default:
@ -2052,7 +2050,6 @@ Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence)
default:
return SDL_SetError("Unknown value for 'whence'");
}
whence = SEEK_SET;
ret = lseek(ctx->hidden.androidio.fd, (off_t)offset, SEEK_SET);
if (ret == -1) return -1;
@ -2508,7 +2505,6 @@ void SDL_AndroidBackButton(void)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midManualBackButton);
return;
}
const char * SDL_AndroidGetInternalStoragePath(void)

View File

@ -48,7 +48,6 @@ void Android_InitTouch(void)
void Android_QuitTouch(void)
{
return;
}
void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)

View File

@ -137,7 +137,7 @@ SDL_bool Android_Vulkan_CreateSurface(_THIS,
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR =
(PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(
(VkInstance)instance,
instance,
"vkCreateAndroidSurfaceKHR");
VkAndroidSurfaceCreateInfoKHR createInfo;
VkResult result;