public void alcGetInteger(int param, IntBuffer buffer, int size) { joalAlc.alcGetIntegerv(getALCDevice(), param, size, buffer); }
public String alcGetString(int parameter) { return joalAlc.alcGetString(getALCDevice(), parameter); }
public boolean alcIsExtensionPresent(String extension) { return joalAlc.alcIsExtensionPresent(getALCDevice(), extension); }
private ALCdevice getALCDevice() { ALCcontext ctx = joalAlc.alcGetCurrentContext(); if (ctx == null) { return null; } ALCdevice device = joalAlc.alcGetContextsDevice(ctx); if (device == null) { return null; } return device; }
device = alc.alcOpenDevice(null); if (device == null) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error opening default OpenAL device"); deviceSpecifier = alc.alcGetString(device, ALCConstants.ALC_DEVICE_SPECIFIER); if (deviceSpecifier == null) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error getting specifier for default OpenAL device"); context = alc.alcCreateContext(device, null); if (context == null) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error creating OpenAL context for "+deviceSpecifier); if ( alc.alcGetError(device) != ALCConstants.ALC_NO_ERROR ) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error making OpenAL context current"); hasALC_thread_local_context = alc.alcIsExtensionPresent(null, ALC_EXT_thread_local_context) || alc.alcIsExtensionPresent(device, ALC_EXT_thread_local_context) ; clearPreALError("init."+checkErrIter++); preferredAudioFormat = new AudioFormat(querySampleRate(), DefaultFormat.sampleSize, DefaultFormat.channelCount, DefaultFormat.signed, DefaultFormat.fixedP, DefaultFormat.planar, DefaultFormat.littleEndian); System.out.println("ALAudioSink: OpenAL Extensions:"+al.alGetString(ALConstants.AL_EXTENSIONS)); clearPreALError("init."+checkErrIter++); System.out.println("ALAudioSink: Null device OpenAL Extensions:"+alc.alcGetString(null, ALCConstants.ALC_EXTENSIONS)); clearPreALError("init."+checkErrIter++); System.out.println("ALAudioSink: Device "+deviceSpecifier+" OpenAL Extensions:"+alc.alcGetString(device, ALCConstants.ALC_EXTENSIONS)); System.out.println("ALAudioSink: hasSOFTBufferSamples "+hasSOFTBufferSamples); System.out.println("ALAudioSink: hasALC_thread_local_context "+hasALC_thread_local_context);
final ALCdevice d = alc.alcOpenDevice(deviceName); if (d == null) { throw new ALException("Error opening default OpenAL device"); final ALCcontext c = alc.alcCreateContext(d, null); if (c == null) { alc.alcCloseDevice(d); throw new ALException("Error creating OpenAL context"); alc.alcMakeContextCurrent(c); if (alc.alcGetError(d) != 0) { alc.alcDestroyContext(c); alc.alcCloseDevice(d); throw new ALException("Error making OpenAL context current");
/** Shuts down the OpenAL Utility Toolkit; releases and destroys the internal OpenAL context and closes the output device. Must be called from the same thread as alutInit(). Most applications should not need to call this; only those which wish to toggle sound on / off at run time by initializing and un-initializing OpenAL need to call it. */ public static synchronized void alutExit() throws ALException { if (context == null) { throw new ALException("Not initialized"); } alc.alcMakeContextCurrent(null); alc.alcDestroyContext(context); alc.alcCloseDevice(device); context = null; device = null; initializingThread = null; }
private final int querySampleRate() { final int sampleRate; final int[] value = new int[1]; alc.alcGetIntegerv(device, ALCConstants.ALC_FREQUENCY, 1, value, 0); final int alcErr = alc.alcGetError(device); final int alErr = al.alGetError(); if ( ALCConstants.ALC_NO_ERROR == alcErr && ALConstants.AL_NO_ERROR == alErr && 0 != value[0] ) { sampleRate = value[0]; } else { sampleRate = DefaultFormat.sampleRate; } if( DEBUG ) { System.err.println("ALAudioSink.querySampleRate: err [alc "+toHexString(alcErr)+", al "+toHexString(alErr)+"], freq: "+value[0]+" -> "+sampleRate); } return sampleRate; }
private final void lockContext() { lock.lock(); if( hasALC_thread_local_context ) { alExt.alcSetThreadContext(context); } else { alc.alcMakeContextCurrent(context); } final int alcErr = alc.alcGetError(null); if( ALCConstants.ALC_NO_ERROR != alcErr ) { final String err = getThreadName()+": ALCError "+toHexString(alcErr)+" while makeCurrent. "+this; System.err.println(err); Thread.dumpStack(); lock.unlock(); throw new RuntimeException(err); } final int alErr = al.alGetError(); if( ALCConstants.ALC_NO_ERROR != alErr ) { if( DEBUG ) { System.err.println(getThreadName()+": Prev - ALError "+toHexString(alErr)+" @ makeCurrent. "+this); Thread.dumpStack(); } } } private final void unlockContext() {
/** * Makes the specified context the current context. * * @param context the context to make current. */ public static void makeContextCurrent(final Context context) { ALCcontext realContext = null; if (context != null) { realContext = context.realContext; } alc.alcMakeContextCurrent(realContext); }
/** * destroys this context freeing its resources. */ public void destroy() { alc.alcDestroyContext(realContext); }
/** * closes the device, freeing its resources. */ public void close() { alc.alcCloseDevice(realDevice); } }
private boolean checkALError(final String prefix) { final int alcErr = alc.alcGetError(device); final int alErr = al.alGetError(); final boolean ok = ALCConstants.ALC_NO_ERROR == alcErr && ALConstants.AL_NO_ERROR == alErr; if( DEBUG ) { System.err.println("ALAudioSink."+prefix+": ok "+ok+", err [alc "+toHexString(alcErr)+", al "+toHexString(alErr)+"]"); } return ok; }
/** * Creates a new Sound3D Context for a specified device. * * @param device The device the Context is being created for. * * @return The new Sound3D context. */ public static Context createContext(final Device device) { Context result = null; final ALCcontext realContext = alc.alcCreateContext(device.realDevice, null); result = new Context(alc, realContext, device); return result; }
/** * Opens the specifified audio device. * * @param deviceName The specified device name, On windows this will be * DirectSound3D. We will be automating device discovery in upcoming versions * of this class. * * @return The device described by the specifed name. */ public static Device openDevice(final String deviceName) { Device result = null; final ALCdevice realDevice = alc.alcOpenDevice(deviceName); result = new Device(alc, realDevice); return result; }
device = alc.alcOpenDevice(null); if (device == null) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error opening default OpenAL device"); deviceSpecifier = alc.alcGetString(device, ALCConstants.ALC_DEVICE_SPECIFIER); if (deviceSpecifier == null) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error getting specifier for default OpenAL device"); context = alc.alcCreateContext(device, null); if (context == null) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error creating OpenAL context for "+deviceSpecifier); if ( alc.alcGetError(device) != ALCConstants.ALC_NO_ERROR ) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error making OpenAL context current"); hasALC_thread_local_context = alc.alcIsExtensionPresent(null, ALC_EXT_thread_local_context) || alc.alcIsExtensionPresent(device, ALC_EXT_thread_local_context) ; clearPreALError("init."+checkErrIter++); preferredAudioFormat = new AudioFormat(querySampleRate(), DefaultFormat.sampleSize, DefaultFormat.channelCount, DefaultFormat.signed, DefaultFormat.fixedP, DefaultFormat.planar, DefaultFormat.littleEndian); System.out.println("ALAudioSink: OpenAL Extensions:"+al.alGetString(ALConstants.AL_EXTENSIONS)); clearPreALError("init."+checkErrIter++); System.out.println("ALAudioSink: Null device OpenAL Extensions:"+alc.alcGetString(null, ALCConstants.ALC_EXTENSIONS)); clearPreALError("init."+checkErrIter++); System.out.println("ALAudioSink: Device "+deviceSpecifier+" OpenAL Extensions:"+alc.alcGetString(device, ALCConstants.ALC_EXTENSIONS)); System.out.println("ALAudioSink: hasSOFTBufferSamples "+hasSOFTBufferSamples); System.out.println("ALAudioSink: hasALC_thread_local_context "+hasALC_thread_local_context);
private final int querySampleRate() { final int sampleRate; final int[] value = new int[1]; alc.alcGetIntegerv(device, ALCConstants.ALC_FREQUENCY, 1, value, 0); final int alcErr = alc.alcGetError(device); final int alErr = al.alGetError(); if ( ALCConstants.ALC_NO_ERROR == alcErr && ALConstants.AL_NO_ERROR == alErr && 0 != value[0] ) { sampleRate = value[0]; } else { sampleRate = DefaultFormat.sampleRate; } if( DEBUG ) { System.err.println("ALAudioSink.querySampleRate: err [alc "+toHexString(alcErr)+", al "+toHexString(alErr)+"], freq: "+value[0]+" -> "+sampleRate); } return sampleRate; }
private final void lockContext() { lock.lock(); if( hasALC_thread_local_context ) { alExt.alcSetThreadContext(context); } else { alc.alcMakeContextCurrent(context); } final int alcErr = alc.alcGetError(null); if( ALCConstants.ALC_NO_ERROR != alcErr ) { final String err = getThreadName()+": ALCError "+toHexString(alcErr)+" while makeCurrent. "+this; System.err.println(err); ExceptionUtils.dumpStack(System.err); lock.unlock(); throw new RuntimeException(err); } final int alErr = al.alGetError(); if( ALCConstants.ALC_NO_ERROR != alErr ) { if( DEBUG ) { System.err.println(getThreadName()+": Prev - ALError "+toHexString(alErr)+" @ makeCurrent. "+this); ExceptionUtils.dumpStack(System.err); } } } private final void unlockContext() {
private ALCdevice getALCDevice() { ALCcontext ctx = joalAlc.alcGetCurrentContext(); if (ctx == null) { return null; } ALCdevice device = joalAlc.alcGetContextsDevice(ctx); if (device == null) { return null; } return device; }
private final void unlockContext() { if( hasALC_thread_local_context ) { alExt.alcSetThreadContext(null); } else { alc.alcMakeContextCurrent(null); } lock.unlock(); } private final void destroyContext() {