diff options
author | athomas <[email protected]> | 2003-06-27 22:51:23 +0000 |
---|---|---|
committer | athomas <[email protected]> | 2003-06-27 22:51:23 +0000 |
commit | ab28a11b32eaccf5c958cee5aeaf21918d4d534c (patch) | |
tree | 8950c03c1734c2893134127911747ab97d4764d8 /src/java | |
parent | 02667f25fb77eb595948d731dfcd1f66d8e52373 (diff) |
added synchronization mechanism around makeContextCurrent by adding a freeCurrentContext method and n object lock
fixes some typos as well
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@41 03bf7f67-59de-4072-a415-9a990d468a3f
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/net/java/games/joal/ALCImpl.java | 29 | ||||
-rw-r--r-- | src/java/net/java/games/sound3d/Source.java | 6 |
2 files changed, 23 insertions, 12 deletions
diff --git a/src/java/net/java/games/joal/ALCImpl.java b/src/java/net/java/games/joal/ALCImpl.java index ed5906e..d621a0a 100644 --- a/src/java/net/java/games/joal/ALCImpl.java +++ b/src/java/net/java/games/joal/ALCImpl.java @@ -37,16 +37,16 @@ import java.util.HashMap; final class ALCImpl implements ALC { private final HashMap contextMap = new HashMap(); + private static Object lock = new Object(); ALCImpl() { System.loadLibrary("joal"); - /* + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { exit(); } })); - */ } public Device alcOpenDevice(String deviceName) { @@ -84,17 +84,28 @@ final class ALCImpl implements ALC { public int alcMakeContextCurrent(Context context) { int result = 0; - int pointer = 0; - - if (context != null) { - pointer = context.pointer; + synchronized(lock) { + int pointer = 0; + if (context != null) { + pointer = context.pointer; + } + result = makeContextCurrentNative(pointer); + try { + lock.wait(); + } catch (InterruptedException e) { + result = 0; + } } - - result = makeContextCurrentNative(pointer); - return result; } + public void alcFreeCurrentContext() { + synchronized(lock) { + makeContextCurrentNative(0); + lock.notifyAll(); + } + } + private native int makeContextCurrentNative(int pointer); public void alcProcessContext(Context context) { diff --git a/src/java/net/java/games/sound3d/Source.java b/src/java/net/java/games/sound3d/Source.java index b6ecf37..5e4183d 100644 --- a/src/java/net/java/games/sound3d/Source.java +++ b/src/java/net/java/games/sound3d/Source.java @@ -148,7 +148,7 @@ public final class Source { * Gets the max distance where there will no longer be any attenuation of * the source. * - * @param the max ditance for source attentuation. + * @return the max ditance for source attentuation. */ public float getMaxDistance() { float[] result = new float[1]; @@ -255,7 +255,7 @@ public final class Source { /** * Gets the gain when outside the oriented cone. * - * @param coneOuterGain the gain when outside the oriented cone. + * @return the gain when outside the oriented cone. */ public float getConeOuterGain() { float[] result = new float[1]; @@ -422,7 +422,7 @@ public final class Source { /** * indicates whether looping is turned on or off. * - * @param isLooping true-looping is on, false-looping is off + * @return true-looping is on, false-looping is off */ public boolean getLooping() { boolean result = false; |