diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/SoundResource.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/scape/SoundResource.java')
| -rw-r--r-- | NET/worlds/scape/SoundResource.java | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/NET/worlds/scape/SoundResource.java b/NET/worlds/scape/SoundResource.java new file mode 100644 index 0000000..a564a8c --- /dev/null +++ b/NET/worlds/scape/SoundResource.java @@ -0,0 +1,167 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import java.io.PrintStream; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ class SoundResource +/* */ { +/* 38 */ private static SoundResource instance = null; +/* */ +/* */ public static final int RSX = 1; +/* */ +/* */ public static final int RA = 2; +/* */ +/* */ private static void debugOut(int n, String s) +/* */ { +/* 46 */ if (Sound.debugLevel > n) System.out.println(s); +/* */ } +/* */ +/* */ public static SoundResource instance() +/* */ { +/* 51 */ if (instance == null) { +/* 52 */ debugOut(6, "Instantiating a new SoundResource"); +/* 53 */ instance = new SoundResource(); +/* */ } +/* 55 */ return instance; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 64 */ private int currentPlayer = 0; +/* */ +/* */ +/* */ +/* */ +/* */ +/* 70 */ private int counter = 0; +/* */ +/* */ +/* */ +/* */ +/* 75 */ private boolean isShutdownTime = false; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean syncLock(int type) +/* */ { +/* 89 */ debugOut(6, "Calling syncLock with type " + type + " counter " + this.counter); +/* 90 */ if (this.isShutdownTime) +/* 91 */ return false; +/* 92 */ if (type != this.currentPlayer) { +/* 93 */ this.currentPlayer = type; +/* 94 */ if (this.counter > 0) { +/* 95 */ this.isShutdownTime = true; +/* */ } +/* */ else { +/* 98 */ this.currentPlayer = type; +/* 99 */ this.counter = 1; +/* */ } +/* */ } +/* */ else { +/* 103 */ this.counter += 1; } +/* 104 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized void asyncLock() +/* */ { +/* 114 */ debugOut(6, "SoundResource::asyncLock with " + this.isShutdownTime); +/* */ +/* 116 */ boolean shutdown = false; +/* 117 */ while (this.isShutdownTime) { +/* 118 */ shutdown = true; +/* 119 */ Thread.yield(); +/* 120 */ debugOut(6, "asyncLock yield"); +/* */ } +/* */ +/* */ +/* */ +/* 125 */ if (shutdown) { +/* 126 */ debugOut(6, "asyncLock: adding artificial delay"); +/* 127 */ try { Thread.sleep(500L); +/* */ } +/* */ catch (InterruptedException localInterruptedException) {} +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean syncUnlock() +/* */ { +/* 139 */ debugOut(6, "SoundResource::syncUnlock with " + this.counter); +/* */ +/* 141 */ boolean rv = false; +/* 142 */ this.counter -= 1; +/* 143 */ if (this.counter <= 0) +/* 144 */ rv = true; +/* 145 */ if ((this.counter <= 0) && (this.isShutdownTime)) { +/* 146 */ this.counter = 1; +/* 147 */ this.isShutdownTime = false; +/* */ } +/* */ +/* 150 */ return rv; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean isOK() +/* */ { +/* 159 */ return !this.isShutdownTime; +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\SoundResource.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |