From 9eb33b0016e8f0781140a3b03509562cb6d95bc1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 9 Jul 2023 21:16:28 +0200 Subject: ALAudioSink.destroy(): Shutdown alEventCallbackSOFT properly (only if hasAL_SOFT_events, 1st disable all events); growBuffers(): No pre-condition exception for hasAL_SOFT_events --- src/java/com/jogamp/openal/util/ALAudioSink.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/java/com/jogamp/openal/util/ALAudioSink.java b/src/java/com/jogamp/openal/util/ALAudioSink.java index cc74be7..e579084 100644 --- a/src/java/com/jogamp/openal/util/ALAudioSink.java +++ b/src/java/com/jogamp/openal/util/ALAudioSink.java @@ -639,11 +639,7 @@ public final class ALAudioSink implements AudioSink { } if( hasAL_SOFT_events ) { alExt.alEventCallbackSOFT(alEventCallback, context.getALContext()); - alExt.alEventControlSOFT(1, new int[] { ALExtConstants.AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT - // , ALExtConstants.AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT - // , ALExtConstants.AL_EVENT_TYPE_DISCONNECTED_SOFT - }, 0, true); - System.err.println("CALLBACK registered"); + alExt.alEventControlSOFT(1, new int[] { ALExtConstants.AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT }, 0, true); } } finally { if( releaseContext ) { @@ -675,7 +671,7 @@ public final class ALAudioSink implements AudioSink { } */ private boolean growBuffers(final int addByteCount) { - if( !hasAL_SOFT_events && !alFramesFree.isEmpty() || !alFramesPlaying.isFull() ) { + if( !alFramesFree.isEmpty() || !alFramesPlaying.isFull() ) { throw new InternalError("Buffers: Avail is !empty "+alFramesFree+" or Playing is !full "+alFramesPlaying+", while !hasAL_SOFT_events"); } final float addDuration = chosenFormat.getBytesDuration(addByteCount); // [s] @@ -761,7 +757,13 @@ public final class ALAudioSink implements AudioSink { available = false; if( null != context ) { makeCurrent(true /* throw */); - alExt.alEventCallbackSOFT(null, context.getALContext()); + if( hasAL_SOFT_events ) { + alExt.alEventControlSOFT(3, new int[] { ALExtConstants.AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT, + ALExtConstants.AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT, + ALExtConstants.AL_EVENT_TYPE_DISCONNECTED_SOFT + }, 0, false); + alExt.alEventCallbackSOFT(null, context.getALContext()); + } } try { stopImpl(true); -- cgit v1.2.3