From a1316b4514dff6cfa9f0d7e37b8fdc37a1ff7f41 Mon Sep 17 00:00:00 2001 From: "iwg..ic" Date: Wed, 17 Jul 2013 02:25:13 +0000 Subject: [PATCH] Android: Fix issue with AndroidHarness trying to pause audio after app.stop() closed down the audio renderer git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10728 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../audio/android/AndroidOpenALSoftAudioRenderer.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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()) {