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
3.0
iwg..ic 12 years ago
parent 2143e17d99
commit a1316b4514
  1. 11
      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 static final float UPDATE_RATE = 0.05f;
private final Thread audioThread = new Thread(this, "jME3 Audio Thread"); private final Thread audioThread = new Thread(this, "jME3 Audio Thread");
private final AtomicBoolean threadLock = new AtomicBoolean(false); private final AtomicBoolean threadLock = new AtomicBoolean(false);
private boolean initialized = false;
public AndroidOpenALSoftAudioRenderer() { public AndroidOpenALSoftAudioRenderer() {
} }
@ -98,6 +99,8 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run
threadLock.notifyAll(); threadLock.notifyAll();
} }
initialized = true;
long updateRateNanos = (long) (UPDATE_RATE * 1000000000); long updateRateNanos = (long) (UPDATE_RATE * 1000000000);
mainloop: mainloop:
while (true) { while (true) {
@ -126,6 +129,8 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run
} }
} }
initialized = false;
synchronized (threadLock) { synchronized (threadLock) {
cleanupInThread(); cleanupInThread();
} }
@ -1292,6 +1297,12 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run
} }
public void pauseAll() { 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(); checkDead();
synchronized (threadLock) { synchronized (threadLock) {
while (!threadLock.get()) { while (!threadLock.get()) {

Loading…
Cancel
Save