From 38d03bf5056f7938afcac584bc4321eca49076a1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 9 Jul 2023 14:56:00 +0200 Subject: Sound3d.Context: destroy() shall only 'null' thread-local context if this is current; Expose hasALC_thread_local_context to avoid double checks --- src/java/com/jogamp/openal/sound3d/Context.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/java/com/jogamp/openal/sound3d/Context.java b/src/java/com/jogamp/openal/sound3d/Context.java index 2884f0c..e42f9dc 100644 --- a/src/java/com/jogamp/openal/sound3d/Context.java +++ b/src/java/com/jogamp/openal/sound3d/Context.java @@ -34,7 +34,6 @@ package com.jogamp.openal.sound3d; -import com.jogamp.common.ExceptionUtils; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.openal.*; @@ -51,7 +50,7 @@ public final class Context { private final Device device; private volatile ALCcontext alCtx; private boolean threadContextLocked; - private boolean hasALC_thread_local_context; + public final boolean hasALC_thread_local_context; private static final ThreadLocal currentContext = new ThreadLocal(); /** @@ -64,7 +63,6 @@ public final class Context { this.device = device; this.alCtx = realContext; { - hasALC_thread_local_context = false; final boolean v; if( makeCurrent(false) ) { v = AudioSystem3D.alc.alcIsExtensionPresent(null, ALHelpers.ALC_EXT_thread_local_context) || @@ -165,7 +163,9 @@ public final class Context { lock.lock(); try { destroyImpl(); - currentContext.set(null); + if( currentContext.get() == this ) { + currentContext.set(null); + } // unroll lock ! while(lock.getHoldCount() > 1) { lock.unlock(); -- cgit v1.2.3