From 32247876e837c3dc35766286e1a6190c7fb476e2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 3 Oct 2023 01:27:42 +0200 Subject: ALAudioSink: Allow disabling using AL_SOFT_events via setUseSOFTEvents(boolean) --- make/scripts/tests-win.bat | 5 ++++- src/java/com/jogamp/openal/util/ALAudioSink.java | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 7e702f1..fc62411 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -1,7 +1,10 @@ REM scripts\java-win.bat com.jogamp.openal.JoalVersion %* REM scripts\java-win.bat com.jogamp.openal.test.manual.OpenALTest %* REM scripts\java-win.bat com.jogamp.openal.test.manual.Sound3DTest %* -scripts\java-win.bat com.jogamp.openal.test.junit.ALVersionTest %* +REM scripts\java-win.bat com.jogamp.openal.test.manual.Synth01AL %* +REM scripts\java-win.bat com.jogamp.openal.test.manual.Synth02AL %* +scripts\java-win.bat com.jogamp.openal.test.manual.Synth02bAL %* +REM scripts\java-win.bat com.jogamp.openal.test.junit.ALVersionTest %* REM scripts\java-win.bat com.jogamp.openal.test.junit.ALutWAVLoaderTest %* REM scripts\java-win.bat com.jogamp.openal.test.junit.ALExtLoopbackDeviceSOFTTest %* diff --git a/src/java/com/jogamp/openal/util/ALAudioSink.java b/src/java/com/jogamp/openal/util/ALAudioSink.java index 5612783..98cc397 100644 --- a/src/java/com/jogamp/openal/util/ALAudioSink.java +++ b/src/java/com/jogamp/openal/util/ALAudioSink.java @@ -82,6 +82,7 @@ public final class ALAudioSink implements AudioSink { private boolean hasEXTDouble; private boolean hasALC_thread_local_context; private boolean hasAL_SOFT_events; + private boolean useAL_SOFT_events; private int sourceCount; private float defaultLatency; private float latency; @@ -218,6 +219,7 @@ public final class ALAudioSink implements AudioSink { hasEXTDouble = al.alIsExtensionPresent(ALHelpers.AL_EXT_DOUBLE); hasALC_thread_local_context = context.hasALC_thread_local_context; hasAL_SOFT_events = al.alIsExtensionPresent(ALHelpers.AL_SOFT_events); + useAL_SOFT_events = hasAL_SOFT_events; int checkErrIter = 1; AudioSystem3D.checkError(device, "init."+checkErrIter++, DEBUG, false); @@ -325,6 +327,12 @@ public final class ALAudioSink implements AudioSink { public final boolean hasEXTDouble() { return hasEXTDouble; } /** Return whether OpenAL extension ALC_EXT_thread_local_context is available. */ public final boolean hasALCThreadLocalContext() { return hasALC_thread_local_context; } + /** Return whether OpenAL extension AL_SOFT_events is available. */ + public final boolean hasSOFTEvents() { return hasAL_SOFT_events; } + /** Enable or disable AL_SOFT_events, default is enabled if {@link #hasSOFTEvents()}. */ + public final void setUseSOFTEvents(final boolean v) { useAL_SOFT_events = v; } + /** Returns whether AL_SOFT_events is enabled, default if {@link #hasSOFTEvents()}. */ + public final boolean getUseSOFTEvents(final boolean v) { return useAL_SOFT_events; } /** Return this instance's OpenAL channel layout, set after {@link #init(AudioFormat, float, int, int, int)}. */ public final int getALChannelLayout() { return alChannelLayout; } @@ -354,11 +362,11 @@ public final class ALAudioSink implements AudioSink { final int alFramesFreeSize = alFramesFree != null ? alFramesFree.size() : 0; final int alFramesPlayingSize = alFramesPlaying != null ? alFramesPlaying.size() : 0; return String.format("ALAudioSink[playReq %b, device '%s', ctx 0x%x, alSource %d"+ - ", chosen %s, al[chan %s, type %s, fmt 0x%x, tlc %b, soft %b, latency %.2f/%.2f ms, sources %d]"+ + ", chosen %s, al[chan %s, type %s, fmt 0x%x, tlc %b, soft[buffer %b, events %b/%b], latency %.2f/%.2f ms, sources %d]"+ ", playSpeed %.2f, buffers[total %d, free %d], queued[%d, apts %d, %.1f ms, %d bytes, avg %.2f ms/frame], queue[g %d ms, l %d ms]]", playRequested, device.getName(), ctxHash, alSource.getID(), chosenFormat, ALHelpers.alChannelLayoutName(alChannelLayout), ALHelpers.alSampleTypeName(alSampleType), - alFormat, hasALC_thread_local_context, hasSOFTBufferSamples, + alFormat, hasALC_thread_local_context, hasSOFTBufferSamples, useAL_SOFT_events, hasAL_SOFT_events, 1000f*latency, 1000f*defaultLatency, sourceCount, playSpeed, alBuffersLen, alFramesFreeSize, alFramesPlayingSize, getPTS(), 1000f*getQueuedTime(), alBufferBytesQueued, 1000f*avgFrameDuration, queueGrowAmount, queueLimit @@ -637,7 +645,7 @@ public final class ALAudioSink implements AudioSink { alFramesPlaying.dump(System.err, "Playi-init"); } } - if( hasAL_SOFT_events ) { + if( hasAL_SOFT_events && useAL_SOFT_events ) { alExt.alEventCallbackSOFT(alEventCallback, context.getALContext()); alExt.alEventControlSOFT(1, new int[] { ALExtConstants.AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT }, 0, true); } @@ -828,7 +836,7 @@ public final class ALAudioSink implements AudioSink { boolean onceBusyDebug = true; final long t0 = DEBUG ? Clock.currentNanos() : 0; do { - if( hasAL_SOFT_events ) { + if( hasAL_SOFT_events && useAL_SOFT_events ) { synchronized( eventReleasedBuffersLock ) { while( wait && alBufferBytesQueued > 0 && eventReleasedBuffers < releaseBufferLimes ) { wait_cycles++; -- cgit v1.2.3