Initializes ALUT (JOAL) in the static initializer to avoid freezing everything
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9895 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
03fe815bd2
commit
e4d776ae0e
@ -78,6 +78,10 @@ public class JoalAudioRenderer implements AudioRenderer, Runnable {
|
||||
private ALC alc;
|
||||
private AL al;
|
||||
|
||||
static {
|
||||
ALut.alutInit();
|
||||
}
|
||||
|
||||
public JoalAudioRenderer() {
|
||||
}
|
||||
|
||||
@ -139,7 +143,6 @@ public class JoalAudioRenderer implements AudioRenderer, Runnable {
|
||||
|
||||
public void initInThread() {
|
||||
try {
|
||||
ALut.alutInit();
|
||||
alc = ALFactory.getALC();
|
||||
al = ALFactory.getAL();
|
||||
|
||||
@ -174,57 +177,57 @@ public class JoalAudioRenderer implements AudioRenderer, Runnable {
|
||||
throw new ALException("Error making OpenAL context current");
|
||||
}
|
||||
|
||||
// Find maximum # of sources supported by this implementation
|
||||
ArrayList<Integer> channelList = new ArrayList<Integer>();
|
||||
IntBuffer channelsNioBuffer = Buffers.newDirectIntBuffer(MAX_NUM_CHANNELS);
|
||||
al.alGenSources(MAX_NUM_CHANNELS, channelsNioBuffer);
|
||||
for (int i = 0; i < MAX_NUM_CHANNELS; i++) {
|
||||
int chan = channelsNioBuffer.get(i);
|
||||
if (chan != 0) {
|
||||
channelList.add(chan);
|
||||
// Find maximum # of sources supported by this implementation
|
||||
ArrayList<Integer> channelList = new ArrayList<Integer>();
|
||||
IntBuffer channelsNioBuffer = Buffers.newDirectIntBuffer(MAX_NUM_CHANNELS);
|
||||
al.alGenSources(MAX_NUM_CHANNELS, channelsNioBuffer);
|
||||
for (int i = 0; i < MAX_NUM_CHANNELS; i++) {
|
||||
int chan = channelsNioBuffer.get(i);
|
||||
if (chan != 0) {
|
||||
channelList.add(chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
channels = new int[channelList.size()];
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
channels[i] = channelList.get(i);
|
||||
}
|
||||
channels = new int[channelList.size()];
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
channels[i] = channelList.get(i);
|
||||
}
|
||||
|
||||
ib = BufferUtils.createIntBuffer(channels.length);
|
||||
chanSrcs = new AudioNode[channels.length];
|
||||
ib = BufferUtils.createIntBuffer(channels.length);
|
||||
chanSrcs = new AudioNode[channels.length];
|
||||
|
||||
logger.log(Level.INFO, "AudioRenderer supports {0} channels", channels.length);
|
||||
logger.log(Level.INFO, "AudioRenderer supports {0} channels", channels.length);
|
||||
|
||||
supportEfx = alc.alcIsExtensionPresent(device, "ALC_EXT_EFX");
|
||||
if (supportEfx) {
|
||||
ib.position(0).limit(1);
|
||||
alc.alcGetIntegerv(device, AL.ALC_EFX_MAJOR_VERSION, 1, ib);
|
||||
int major = ib.get(0);
|
||||
ib.position(0).limit(1);
|
||||
alc.alcGetIntegerv(device, AL.ALC_EFX_MINOR_VERSION, 1, ib);
|
||||
int minor = ib.get(0);
|
||||
logger.log(Level.INFO, "Audio effect extension version: {0}.{1}", new Object[]{major, minor});
|
||||
supportEfx = alc.alcIsExtensionPresent(device, "ALC_EXT_EFX");
|
||||
if (supportEfx) {
|
||||
ib.position(0).limit(1);
|
||||
alc.alcGetIntegerv(device, AL.ALC_EFX_MAJOR_VERSION, 1, ib);
|
||||
int major = ib.get(0);
|
||||
ib.position(0).limit(1);
|
||||
alc.alcGetIntegerv(device, AL.ALC_EFX_MINOR_VERSION, 1, ib);
|
||||
int minor = ib.get(0);
|
||||
logger.log(Level.INFO, "Audio effect extension version: {0}.{1}", new Object[]{major, minor});
|
||||
|
||||
alc.alcGetIntegerv(device, AL.ALC_MAX_AUXILIARY_SENDS, 1, ib);
|
||||
auxSends = ib.get(0);
|
||||
logger.log(Level.INFO, "Audio max auxilary sends: {0}", auxSends);
|
||||
alc.alcGetIntegerv(device, AL.ALC_MAX_AUXILIARY_SENDS, 1, ib);
|
||||
auxSends = ib.get(0);
|
||||
logger.log(Level.INFO, "Audio max auxilary sends: {0}", auxSends);
|
||||
|
||||
// create slot
|
||||
ib.position(0).limit(1);
|
||||
al.alGenAuxiliaryEffectSlots(1, ib);
|
||||
reverbFxSlot = ib.get(0);
|
||||
// create slot
|
||||
ib.position(0).limit(1);
|
||||
al.alGenAuxiliaryEffectSlots(1, ib);
|
||||
reverbFxSlot = ib.get(0);
|
||||
|
||||
// create effect
|
||||
ib.position(0).limit(1);
|
||||
al.alGenEffects(1, ib);
|
||||
reverbFx = ib.get(0);
|
||||
al.alEffecti(reverbFx, AL.AL_EFFECT_TYPE, AL.AL_EFFECT_REVERB);
|
||||
// create effect
|
||||
ib.position(0).limit(1);
|
||||
al.alGenEffects(1, ib);
|
||||
reverbFx = ib.get(0);
|
||||
al.alEffecti(reverbFx, AL.AL_EFFECT_TYPE, AL.AL_EFFECT_REVERB);
|
||||
|
||||
// attach reverb effect to effect slot
|
||||
al.alAuxiliaryEffectSloti(reverbFxSlot, AL.AL_EFFECTSLOT_EFFECT, reverbFx);
|
||||
} else {
|
||||
logger.log(Level.WARNING, "OpenAL EFX not available! Audio effects won't work.");
|
||||
}
|
||||
// attach reverb effect to effect slot
|
||||
al.alAuxiliaryEffectSloti(reverbFxSlot, AL.AL_EFFECTSLOT_EFFECT, reverbFx);
|
||||
} else {
|
||||
logger.log(Level.WARNING, "OpenAL EFX not available! Audio effects won't work.");
|
||||
}
|
||||
} catch (ALException ex) {
|
||||
logger.log(Level.SEVERE, "Failed to load audio library", ex);
|
||||
audioDisabled = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user