diff options
-rw-r--r-- | src/java/com/jogamp/openal/util/ALHelpers.java | 19 | ||||
-rw-r--r-- | src/java/jogamp/openal/util/ALAudioSink.java | 59 |
2 files changed, 67 insertions, 11 deletions
diff --git a/src/java/com/jogamp/openal/util/ALHelpers.java b/src/java/com/jogamp/openal/util/ALHelpers.java index 7c2b0d4..a666049 100644 --- a/src/java/com/jogamp/openal/util/ALHelpers.java +++ b/src/java/com/jogamp/openal/util/ALHelpers.java @@ -55,12 +55,19 @@ public class ALHelpers { * @param alChannelLayout AL channel layout, see {@link #getDefaultALChannelLayout(int)} * @param alSampleType AL sample type, see {@link #getALSampleType(int, boolean, boolean)}. * @param hasSOFTBufferSamples true if having extension <code>AL_SOFT_buffer_samples</code>, otherwise false + * @param hasEXTMcFormats true if having extension <code>AL_EXT_MCFORMATS</code>, otherwise false + * @param hasEXTFloat32 true if having extension <code>AL_EXT_FLOAT32</code>, otherwise false + * @param hasEXTDouble true if having extension <code>AL_EXT_DOUBLE</code>, otherwise false * @param al AL instance * @param alExt ALExt instance * @return AL buffer format */ public static final int getALFormat(final int alChannelLayout, final int alSampleType, - final boolean hasSOFTBufferSamples, final AL al, final ALExt alExt) { + final boolean hasSOFTBufferSamples, + final boolean hasEXTMcFormats, + final boolean hasEXTFloat32, + final boolean hasEXTDouble, + final AL al, final ALExt alExt) { int format = AL_NONE; /* If using AL_SOFT_buffer_samples, try looking through its formats */ @@ -154,7 +161,7 @@ public class ALHelpers { format = AL_FORMAT_MONO8; else if(alChannelLayout == AL_STEREO_SOFT) format = AL_FORMAT_STEREO8; - else if(al.alIsExtensionPresent("AL_EXT_MCFORMATS")) + else if( hasEXTMcFormats ) { if(alChannelLayout == AL_QUAD_SOFT) format = al.alGetEnumValue("AL_FORMAT_QUAD8"); @@ -172,7 +179,7 @@ public class ALHelpers { format = AL_FORMAT_MONO16; else if(alChannelLayout == AL_STEREO_SOFT) format = AL_FORMAT_STEREO16; - else if(al.alIsExtensionPresent("AL_EXT_MCFORMATS")) + else if( hasEXTMcFormats ) { if(alChannelLayout == AL_QUAD_SOFT) format = al.alGetEnumValue("AL_FORMAT_QUAD16"); @@ -184,13 +191,13 @@ public class ALHelpers { format = al.alGetEnumValue("AL_FORMAT_71CHN16"); } } - else if(alSampleType == AL_FLOAT_SOFT && al.alIsExtensionPresent("AL_EXT_FLOAT32")) + else if(alSampleType == AL_FLOAT_SOFT && hasEXTFloat32) { if(alChannelLayout == AL_MONO_SOFT) format = al.alGetEnumValue("AL_FORMAT_MONO_FLOAT32"); else if(alChannelLayout == AL_STEREO_SOFT) format = al.alGetEnumValue("AL_FORMAT_STEREO_FLOAT32"); - else if(al.alIsExtensionPresent("AL_EXT_MCFORMATS")) + else if( hasEXTMcFormats ) { if(alChannelLayout == AL_QUAD_SOFT) format = al.alGetEnumValue("AL_FORMAT_QUAD32"); @@ -202,7 +209,7 @@ public class ALHelpers { format = al.alGetEnumValue("AL_FORMAT_71CHN32"); } } - else if(alSampleType == AL_DOUBLE_SOFT && al.alIsExtensionPresent("AL_EXT_DOUBLE")) + else if(alSampleType == AL_DOUBLE_SOFT && hasEXTDouble) { if(alChannelLayout == AL_MONO_SOFT) format = al.alGetEnumValue("AL_FORMAT_MONO_DOUBLE"); diff --git a/src/java/jogamp/openal/util/ALAudioSink.java b/src/java/jogamp/openal/util/ALAudioSink.java index 418da1f..824c227 100644 --- a/src/java/jogamp/openal/util/ALAudioSink.java +++ b/src/java/jogamp/openal/util/ALAudioSink.java @@ -57,7 +57,16 @@ import com.jogamp.openal.util.ALHelpers; */ public class ALAudioSink implements AudioSink { + /** + * [openal-soft >= 1.18.0](https://github.com/kcat/openal-soft/blob/master/ChangeLog) + * - Removed support for the AL_SOFT_buffer_samples and AL_SOFT_buffer_sub_data + * extensions. Due to conflicts with AL_EXT_SOURCE_RADIUS. + */ private static final String AL_SOFT_buffer_samples = "AL_SOFT_buffer_samples"; + private static final String AL_EXT_MCFORMATS = "AL_EXT_MCFORMATS"; + private static final String AL_EXT_FLOAT32 = "AL_EXT_FLOAT32"; + private static final String AL_EXT_DOUBLE = "AL_EXT_DOUBLE"; + private static final String ALC_EXT_thread_local_context = "ALC_EXT_thread_local_context"; private static final boolean DEBUG_TRACE; private static final ALC alc; @@ -68,6 +77,9 @@ public class ALAudioSink implements AudioSink { private String deviceSpecifier; private ALCdevice device; private boolean hasSOFTBufferSamples; + private boolean hasEXTMcFormats; + private boolean hasEXTFloat32; + private boolean hasEXTDouble; private boolean hasALC_thread_local_context; private int preferredSampleRate; private AudioFormat preferredAudioFormat; @@ -194,8 +206,10 @@ public class ALAudioSink implements AudioSink { if ( alc.alcGetError(device) != ALCConstants.ALC_NO_ERROR ) { throw new RuntimeException(getThreadName()+": ALAudioSink: Error making OpenAL context current"); } - hasSOFTBufferSamples = al.alIsExtensionPresent(AL_SOFT_buffer_samples); + hasEXTMcFormats = al.alIsExtensionPresent(AL_EXT_MCFORMATS); + hasEXTFloat32 = al.alIsExtensionPresent(AL_EXT_FLOAT32); + hasEXTDouble = al.alIsExtensionPresent(AL_EXT_DOUBLE); hasALC_thread_local_context = alc.alcIsExtensionPresent(null, ALC_EXT_thread_local_context) || alc.alcIsExtensionPresent(device, ALC_EXT_thread_local_context) ; clearPreALError("init."+checkErrIter++); @@ -218,8 +232,12 @@ public class ALAudioSink implements AudioSink { System.out.println(" Version: "+alcvers[0]+"."+alcvers[1]); System.out.println(" Extensions: "+alc.alcGetString(device, ALCConstants.ALC_EXTENSIONS)); System.out.println("ALAudioSink: hasSOFTBufferSamples "+hasSOFTBufferSamples); + System.out.println("ALAudioSink: hasEXTMcFormats "+hasEXTMcFormats); + System.out.println("ALAudioSink: hasEXTFloat32 "+hasEXTFloat32); + System.out.println("ALAudioSink: hasEXTDouble "+hasEXTDouble); System.out.println("ALAudioSink: hasALC_thread_local_context "+hasALC_thread_local_context); System.out.println("ALAudioSink: preferredAudioFormat "+preferredAudioFormat); + System.out.println("ALAudioSink: maxSupportedChannels "+getMaxSupportedChannels()); clearPreALError("init."+checkErrIter++); } @@ -391,7 +409,11 @@ public class ALAudioSink implements AudioSink { if( !staticAvailable ) { return 0; } - return hasSOFTBufferSamples ? 8 : 2; + if( hasEXTMcFormats || hasSOFTBufferSamples ) { + return 8; + } else { + return 2; + } } @Override @@ -401,6 +423,9 @@ public class ALAudioSink implements AudioSink { } if( format.planar || !format.littleEndian ) { // FIXME big-endian supported w/ SOFT where it's native format! + if( DEBUG ) { + System.err.println(getThreadName()+": ALAudioSink.isSupported: NO.0 "+format); + } return false; } final int alChannelLayout = ALHelpers.getDefaultALChannelLayout(format.channelCount); @@ -409,13 +434,29 @@ public class ALAudioSink implements AudioSink { if( ALConstants.AL_NONE != alSampleType ) { lockContext(); try { - final int alFormat = ALHelpers.getALFormat(alChannelLayout, alSampleType, hasSOFTBufferSamples, al, alExt); - return ALConstants.AL_NONE != alFormat; + final int alFormat = ALHelpers.getALFormat(alChannelLayout, alSampleType, + hasSOFTBufferSamples, hasEXTMcFormats, hasEXTFloat32, hasEXTDouble, + al, alExt); + if( ALConstants.AL_NONE != alFormat ) { + if( DEBUG ) { + System.err.println(getThreadName()+": ALAudioSink.isSupported: OK "+format+", alFormat "+toHexString(alFormat)); + } + return true; + } else { + if( DEBUG ) { + System.err.println(getThreadName()+": ALAudioSink.isSupported: NO.1 "+format); + } + return false; + } + } finally { unlockContext(); } } } + if( DEBUG ) { + System.err.println(getThreadName()+": ALAudioSink.isSupported: NO.X "+format); + } return false; } @@ -429,12 +470,17 @@ public class ALAudioSink implements AudioSink { lockContext(); try { if( ALConstants.AL_NONE != alChannelLayout && ALConstants.AL_NONE != alSampleType ) { - alFormat = ALHelpers.getALFormat(alChannelLayout, alSampleType, hasSOFTBufferSamples, al, alExt); + alFormat = ALHelpers.getALFormat(alChannelLayout, alSampleType, + hasSOFTBufferSamples, hasEXTMcFormats, hasEXTFloat32, hasEXTDouble, + al, alExt); } else { alFormat = ALConstants.AL_NONE; } if( ALConstants.AL_NONE == alFormat ) { // not supported + if( DEBUG ) { + System.err.println(getThreadName()+": ALAudioSink.init: Not supported: "+requestedFormat+", "+toString()); + } return false; } // Allocate buffers @@ -473,6 +519,9 @@ public class ALAudioSink implements AudioSink { } chosenFormat = requestedFormat; + if( DEBUG ) { + System.err.println(getThreadName()+": ALAudioSink.init: OK "+requestedFormat+", "+toString()); + } return true; } |