Skip to content

Commit

Permalink
Android: some readability: redundant casts, deads stores, redundant c…
Browse files Browse the repository at this point in the history
…ontrol flow
  • Loading branch information
1bsyl committed Oct 31, 2019
1 parent fea3c8b commit 303646a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/core/android/SDL_android.c
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2508,7 +2505,6 @@ void SDL_AndroidBackButton(void)
{
JNIEnv *env = Android_JNI_GetEnv();
(*env)->CallStaticVoidMethod(env, mActivityClass, midManualBackButton);
return;
}

const char * SDL_AndroidGetInternalStoragePath(void)
Expand Down
1 change: 0 additions & 1 deletion src/video/android/SDL_androidtouch.c
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/video/android/SDL_androidvulkan.c
Expand Up @@ -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;
Expand Down

0 comments on commit 303646a

Please sign in to comment.