android: vibrate out of the synchronized section

This commit is contained in:
Flyinghead 2019-04-03 18:49:40 +02:00
parent 2d03662a9a
commit cc26e255e0
1 changed files with 5 additions and 1 deletions

View File

@ -415,16 +415,20 @@ public class VirtualJoystickDelegate {
@Override @Override
public void run() { public void run() {
while (!stopping) { while (!stopping) {
boolean doVibrate;
synchronized (this) { synchronized (this) {
doVibrate = false;
try { try {
this.wait(); this.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
if (vibrate) { if (vibrate) {
vibrator.vibrate(Emulator.vibrationDuration); doVibrate = true;
vibrate = false; vibrate = false;
} }
} }
if (doVibrate)
vibrator.vibrate(Emulator.vibrationDuration);
} }
} }