Share the OpenAL context if one is already created.

This commit is contained in:
Michael Bayne
2017-07-18 19:48:26 -07:00
parent ff4d32a1e2
commit 2197292581
@@ -77,7 +77,7 @@ public class SoundManager
*/ */
public void shutdown () public void shutdown ()
{ {
if (isInitialized()) { if (isInitialized() && !_sharingAL) {
AL.destroy(); AL.destroy();
} }
} }
@@ -201,6 +201,9 @@ public class SoundManager
_rqueue = rqueue; _rqueue = rqueue;
// initialize the OpenAL sound system // initialize the OpenAL sound system
if (AL.isCreated()) {
_sharingAL = true;
} else {
try { try {
AL.create("", 44100, 15, false); AL.create("", 44100, 15, false);
} catch (Exception e) { } catch (Exception e) {
@@ -215,6 +218,7 @@ public class SoundManager
// don't start the background loading thread // don't start the background loading thread
return; return;
} }
}
// configure our LRU map with a removal observer // configure our LRU map with a removal observer
_clips.setRemovalObserver(new LRUHashMap.RemovalObserver<String, ClipBuffer>() { _clips.setRemovalObserver(new LRUHashMap.RemovalObserver<String, ClipBuffer>() {
@@ -411,6 +415,9 @@ public class SoundManager
} }
}; };
/** Whether or not we're sharing an AL context that someone else created. */
protected boolean _sharingAL;
/** Used to get back from the background thread to our "main" thread. */ /** Used to get back from the background thread to our "main" thread. */
protected RunQueue _rqueue; protected RunQueue _rqueue;