From c04726720a57f8db42f2621ad58ff3bd42006c63 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 23 May 2023 01:34:28 +0200 Subject: AudioSink: Refine context locking where supported, have a more usable universal API interface --- src/java/com/jogamp/common/av/AudioSink.java | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/java/com/jogamp/common') diff --git a/src/java/com/jogamp/common/av/AudioSink.java b/src/java/com/jogamp/common/av/AudioSink.java index b4738b3..9c31244 100644 --- a/src/java/com/jogamp/common/av/AudioSink.java +++ b/src/java/com/jogamp/common/av/AudioSink.java @@ -123,16 +123,37 @@ public interface AudioSink { } /** - * Exclusively locks this instance for the calling thread, if implementation utilizes locking. - * @see #unlockExclusive() + * Makes the audio context current on the calling thread, if implementation utilizes context locking. + *

+ * If implementation doesn't utilizes context locking, method always returns true. + *

+ *

+ * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported. + *

+ *

+ * At any point in time one context can only be current by one thread, + * and one thread can only have one context current. + *

+ * @param throwException if true, throws ALException if context is null, current thread holds another context or failed to natively make current + * @return true if current thread holds no other context and context successfully made current, otherwise false + * @see #release() */ - public void lockExclusive(); + public boolean makeCurrent(final boolean throwException); /** - * Releases the exclusive lock for the calling thread, if implementation utilizes locking. - * @see #lockExclusive() + * Releases control of this audio context from the current thread, if implementation utilizes context locking. + *

+ * If implementation doesn't utilizes context locking, method always returns true. + *

+ *

+ * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported. + *

+ * @param throwException if true, throws ALException if context has not been previously made current on current thread + * or native release failed. + * @return true if context has previously been made current on the current thread and successfully released, otherwise false + * @see #makeCurrent() */ - public void unlockExclusive(); + public boolean release(final boolean throwException); /** * Returns the available state of this instance. -- cgit v1.2.3