aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/openal/util/ALAudioSink.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-05-18 06:11:42 +0200
committerSven Gothel <[email protected]>2023-05-18 06:11:42 +0200
commit2e800ac4277d6234cb9dba2afe01a4d8c75fc989 (patch)
tree1fe8dc435dd0a31e14a986d2bbc6ea9486b1c3ad /src/java/com/jogamp/openal/util/ALAudioSink.java
parent869d2eb0ff78bd2bdfafbc8778c9fd38dd991b34 (diff)
ALAudioSink: Don'e check errors before context; Track method of context-locking and release same way; Destroy shall also release context.
Result is 'ALSOFT(WW)' free.
Diffstat (limited to 'src/java/com/jogamp/openal/util/ALAudioSink.java')
-rw-r--r--src/java/com/jogamp/openal/util/ALAudioSink.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/java/com/jogamp/openal/util/ALAudioSink.java b/src/java/com/jogamp/openal/util/ALAudioSink.java
index e763899..1227d83 100644
--- a/src/java/com/jogamp/openal/util/ALAudioSink.java
+++ b/src/java/com/jogamp/openal/util/ALAudioSink.java
@@ -82,6 +82,7 @@ public class ALAudioSink implements AudioSink {
private AudioFormat preferredAudioFormat;
private ALCcontext context;
private final RecursiveLock lock = LockFactory.createRecursiveLock();
+ private boolean threadContextLocked;
private volatile Thread exclusiveThread = null;
/** Playback speed, range [0.5 - 2.0], default 1.0. */
@@ -192,18 +193,15 @@ public class ALAudioSink implements AudioSink {
if (device == null) {
throw new RuntimeException(getThreadName()+": ALAudioSink: Error opening default OpenAL device");
}
- clearPreALError("init.dev");
} else {
device = alDevice;
}
- int checkErrIter = 1;
// Get the device specifier.
deviceSpecifier = alc.alcGetString(device, ALCConstants.ALC_DEVICE_SPECIFIER);
if (deviceSpecifier == null) {
throw new RuntimeException(getThreadName()+": ALAudioSink: Error getting specifier for default OpenAL device");
}
- clearPreALError("init."+checkErrIter++);
if( null == alContext ) {
// Create audio context.
@@ -229,6 +227,7 @@ public class ALAudioSink implements AudioSink {
hasEXTDouble = al.alIsExtensionPresent(ALHelpers.AL_EXT_DOUBLE);
hasALC_thread_local_context = alc.alcIsExtensionPresent(null, ALHelpers.ALC_EXT_thread_local_context) ||
alc.alcIsExtensionPresent(device, ALHelpers.ALC_EXT_thread_local_context) ;
+ int checkErrIter = 1;
clearPreALError("init."+checkErrIter++);
preferredSampleRate = querySampleRate();
preferredAudioFormat = new AudioFormat(preferredSampleRate, DefaultFormat.sampleSize, DefaultFormat.channelCount, DefaultFormat.signed, DefaultFormat.fixedP, DefaultFormat.planar, DefaultFormat.littleEndian);
@@ -361,8 +360,10 @@ public class ALAudioSink implements AudioSink {
lock.lock();
if( hasALC_thread_local_context ) {
alExt.alcSetThreadContext(context);
+ threadContextLocked = true;
} else {
alc.alcMakeContextCurrent(context);
+ threadContextLocked = false;
}
final int alcErr = alc.alcGetError(null);
if( ALCConstants.ALC_NO_ERROR != alcErr ) {
@@ -387,7 +388,7 @@ public class ALAudioSink implements AudioSink {
}
throw new IllegalStateException("Exclusive lock by "+exclusiveThread+", but current is "+Thread.currentThread());
}
- if( hasALC_thread_local_context ) {
+ if( threadContextLocked ) {
alExt.alcSetThreadContext(null);
} else {
alc.alcMakeContextCurrent(null);
@@ -399,6 +400,12 @@ public class ALAudioSink implements AudioSink {
try {
if( null != context ) {
try {
+ exclusiveThread = null;
+ if( threadContextLocked ) {
+ alExt.alcSetThreadContext(null);
+ } else {
+ alc.alcMakeContextCurrent(null);
+ }
alc.alcDestroyContext(context);
} catch (final Throwable t) {
if( DEBUG ) {