diff --git a/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java b/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java index df838d288..e5c98ebec 100644 --- a/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java +++ b/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java @@ -71,6 +71,7 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run private static final float UPDATE_RATE = 0.05f; private final Thread audioThread = new Thread(this, "jME3 Audio Thread"); private final AtomicBoolean threadLock = new AtomicBoolean(false); + private boolean initialized = false; public AndroidOpenALSoftAudioRenderer() { } @@ -98,6 +99,8 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run threadLock.notifyAll(); } + initialized = true; + long updateRateNanos = (long) (UPDATE_RATE * 1000000000); mainloop: while (true) { @@ -126,6 +129,8 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run } } + initialized = false; + synchronized (threadLock) { cleanupInThread(); } @@ -1292,6 +1297,12 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run } public void pauseAll() { + // don't try to pause all audio (mainly from Android activity) if + // the renderer is already closed down + if (!initialized) { + return; + } + checkDead(); synchronized (threadLock) { while (!threadLock.get()) {