diff --git a/android/app-android.cpp b/android/app-android.cpp index f7ab269793..10e18c9d17 100644 --- a/android/app-android.cpp +++ b/android/app-android.cpp @@ -336,15 +336,13 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeRenderer_displayRender(JN glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } + lock_guard guard(frameCommandLock); while (!frameCommands.empty()) { FrameCommand frameCmd; - { - lock_guard guard(frameCommandLock); - frameCmd = frameCommands.front(); - frameCommands.pop(); - } + frameCmd = frameCommands.front(); + frameCommands.pop(); - DLOG("frameCommand %s %s", cmd.command.c_str(), frameCmd.params.c_str()); + DLOG("frameCommand %s %s", frameCmd.command.c_str(), frameCmd.params.c_str()); jstring cmd = env->NewStringUTF(frameCmd.command.c_str()); jstring param = env->NewStringUTF(frameCmd.params.c_str()); diff --git a/android/src/com/henrikrydgard/libnative/NativeActivity.java b/android/src/com/henrikrydgard/libnative/NativeActivity.java index b13eeaddc9..95cedd0170 100644 --- a/android/src/com/henrikrydgard/libnative/NativeActivity.java +++ b/android/src/com/henrikrydgard/libnative/NativeActivity.java @@ -769,35 +769,35 @@ public class NativeActivity extends Activity { inputBox(title, defString, "OK"); return true; } else if (command.equals("vibrate")) { - if (vibrator != null) { - int milliseconds = -1; - if (params != "") { - try { - milliseconds = Integer.parseInt(params); - } catch (NumberFormatException e) { - } + int milliseconds = -1; + if (params != "") { + try { + milliseconds = Integer.parseInt(params); + } catch (NumberFormatException e) { } - // Special parameters to perform standard haptic feedback - // operations - // -1 = Standard keyboard press feedback - // -2 = Virtual key press - // -3 = Long press feedback - // Note that these three do not require the VIBRATE Android - // permission. - switch (milliseconds) { - case -1: - mGLSurfaceView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); - break; - case -2: - mGLSurfaceView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); - break; - case -3: - mGLSurfaceView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - break; - default: + } + // Special parameters to perform standard haptic feedback + // operations + // -1 = Standard keyboard press feedback + // -2 = Virtual key press + // -3 = Long press feedback + // Note that these three do not require the VIBRATE Android + // permission. + switch (milliseconds) { + case -1: + mGLSurfaceView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); + break; + case -2: + mGLSurfaceView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); + break; + case -3: + mGLSurfaceView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + break; + default: + if (vibrator != null) { vibrator.vibrate(milliseconds); - break; } + break; } return true; } else if (command.equals("finish")) {