Share the OpenAL context if one is already created.
This commit is contained in:
@@ -77,7 +77,7 @@ public class SoundManager
|
|||||||
*/
|
*/
|
||||||
public void shutdown ()
|
public void shutdown ()
|
||||||
{
|
{
|
||||||
if (isInitialized()) {
|
if (isInitialized() && !_sharingAL) {
|
||||||
AL.destroy();
|
AL.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,19 +201,23 @@ public class SoundManager
|
|||||||
_rqueue = rqueue;
|
_rqueue = rqueue;
|
||||||
|
|
||||||
// initialize the OpenAL sound system
|
// initialize the OpenAL sound system
|
||||||
try {
|
if (AL.isCreated()) {
|
||||||
AL.create("", 44100, 15, false);
|
_sharingAL = true;
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
log.warning("Failed to initialize sound system.", e);
|
try {
|
||||||
// don't start the background loading thread
|
AL.create("", 44100, 15, false);
|
||||||
return;
|
} catch (Exception e) {
|
||||||
}
|
log.warning("Failed to initialize sound system.", e);
|
||||||
|
// don't start the background loading thread
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int errno = AL10.alGetError();
|
int errno = AL10.alGetError();
|
||||||
if (errno != AL10.AL_NO_ERROR) {
|
if (errno != AL10.AL_NO_ERROR) {
|
||||||
log.warning("Failed to initialize sound system [errno=" + errno + "].");
|
log.warning("Failed to initialize sound system [errno=" + errno + "].");
|
||||||
// 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
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user