Skip to content

Commit a1316b4

Browse files
committed
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
1 parent 2143e17 commit a1316b4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Run
7171
private static final float UPDATE_RATE = 0.05f;
7272
private final Thread audioThread = new Thread(this, "jME3 Audio Thread");
7373
private final AtomicBoolean threadLock = new AtomicBoolean(false);
74+
private boolean initialized = false;
7475

7576
public AndroidOpenALSoftAudioRenderer() {
7677
}
@@ -98,6 +99,8 @@ public void run() {
9899
threadLock.notifyAll();
99100
}
100101

102+
initialized = true;
103+
101104
long updateRateNanos = (long) (UPDATE_RATE * 1000000000);
102105
mainloop:
103106
while (true) {
@@ -126,6 +129,8 @@ public void run() {
126129
}
127130
}
128131

132+
initialized = false;
133+
129134
synchronized (threadLock) {
130135
cleanupInThread();
131136
}
@@ -1292,6 +1297,12 @@ public void deleteAudioData(AudioData ad) {
12921297
}
12931298

12941299
public void pauseAll() {
1300+
// don't try to pause all audio (mainly from Android activity) if
1301+
// the renderer is already closed down
1302+
if (!initialized) {
1303+
return;
1304+
}
1305+
12951306
checkDead();
12961307
synchronized (threadLock) {
12971308
while (!threadLock.get()) {

0 commit comments

Comments
 (0)