diff options
author | Sven Gothel <[email protected]> | 2023-05-18 07:13:12 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-18 07:13:12 +0200 |
commit | b9d73b0d8d8384c19b3827cb2fc270d6d5ed6578 (patch) | |
tree | 18733f7ed2c1fd23d80fbfd05452b874c8f19dc0 /src/java | |
parent | 64b40bd4359cad46ebf62751ea342d80205bd98b (diff) |
ALAudioSink.lockContext(): Only check error state if AL makeContextCurrent()/alcSetThreadContext() fails (returns false)
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/com/jogamp/openal/util/ALAudioSink.java | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/src/java/com/jogamp/openal/util/ALAudioSink.java b/src/java/com/jogamp/openal/util/ALAudioSink.java index 1227d83..24cdeeb 100644 --- a/src/java/com/jogamp/openal/util/ALAudioSink.java +++ b/src/java/com/jogamp/openal/util/ALAudioSink.java @@ -358,28 +358,36 @@ public class ALAudioSink implements AudioSink { throw new IllegalStateException("Exclusive lock by "+exclusiveThread+", but current is "+Thread.currentThread()); } lock.lock(); + final boolean r; if( hasALC_thread_local_context ) { - alExt.alcSetThreadContext(context); + r = alExt.alcSetThreadContext(context); threadContextLocked = true; } else { - alc.alcMakeContextCurrent(context); + r = alc.alcMakeContextCurrent(context); threadContextLocked = false; } - final int alcErr = alc.alcGetError(null); - if( ALCConstants.ALC_NO_ERROR != alcErr ) { - final String err = getThreadName()+": ALCError "+toHexString(alcErr)+" while makeCurrent. "+this; + if( !r ) { + 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); + } + } + final String err = getThreadName()+": ALCError makeCurrent failed. "+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() { if( null != exclusiveThread ) { @@ -388,10 +396,17 @@ public class ALAudioSink implements AudioSink { } throw new IllegalStateException("Exclusive lock by "+exclusiveThread+", but current is "+Thread.currentThread()); } + final boolean r; if( threadContextLocked ) { - alExt.alcSetThreadContext(null); + r = alExt.alcSetThreadContext(null); } else { - alc.alcMakeContextCurrent(null); + r = alc.alcMakeContextCurrent(null); + } + if( DEBUG ) { + if( !r ) { + System.err.println(getThreadName()+": unlockContext failed. "+this); + ExceptionUtils.dumpStack(System.err); + } } lock.unlock(); } |