summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/SoundState.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/SoundState.java
downloadworlds.jar-main.tar.xz
worlds.jar-main.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/SoundState.java')
-rw-r--r--NET/worlds/scape/SoundState.java411
1 files changed, 411 insertions, 0 deletions
diff --git a/NET/worlds/scape/SoundState.java b/NET/worlds/scape/SoundState.java
new file mode 100644
index 0000000..a98d01f
--- /dev/null
+++ b/NET/worlds/scape/SoundState.java
@@ -0,0 +1,411 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.network.Cache;
+/* */ import NET.worlds.network.CacheFile;
+/* */ import NET.worlds.network.URL;
+/* */ import java.io.PrintStream;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ class SoundState
+/* */ implements State
+/* */ {
+/* */ public static final int IDLE = 0;
+/* */ public static final int start = 1;
+/* */ public static final int intel0 = 1000;
+/* */ public static final int intel10 = 1010;
+/* */ public static final int intel11 = 1011;
+/* */ public static final int intel20 = 1020;
+/* */ public static final int intel21 = 1021;
+/* */ public static final int intel30 = 1030;
+/* */ public static final int intel31 = 1031;
+/* */ public static final int intel32 = 1032;
+/* */ public static final int intel33 = 1033;
+/* */ public static final int realAudio0 = 2000;
+/* */ public static final int realAudio10 = 2010;
+/* */ public static final int realAudio11 = 2011;
+/* 81 */ private static SoundState instance = new SoundState();
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ private void debugOut(int n, String s)
+/* */ {
+/* 89 */ if (Sound.debugLevel > n) System.out.println(s);
+/* */ }
+/* */
+/* */ public static State instance() {
+/* 93 */ return instance;
+/* */ }
+/* */
+/* */ public Object doState(StateContext sc, Object obj) {
+/* 97 */ Sound sound = (Sound)sc;
+/* */ Object rv;
+/* 99 */ Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; Object rv; switch (sound.state) {
+/* */ case 1:
+/* 101 */ rv = start(sound, obj);
+/* 102 */ break;
+/* */ case 1000:
+/* 104 */ rv = intel0(sound, obj);
+/* 105 */ break;
+/* */ case 1010:
+/* 107 */ rv = intel10(sound, obj);
+/* 108 */ break;
+/* */ case 1011:
+/* 110 */ rv = intel11(sound, obj);
+/* 111 */ break;
+/* */ case 1020:
+/* 113 */ rv = intel20(sound, obj);
+/* 114 */ break;
+/* */ case 1021:
+/* 116 */ rv = intel21(sound, obj);
+/* 117 */ break;
+/* */ case 1030:
+/* 119 */ rv = intel30(sound, obj);
+/* 120 */ break;
+/* */ case 1031:
+/* 122 */ rv = intel31(sound, obj);
+/* 123 */ break;
+/* */ case 1032:
+/* 125 */ rv = intel32(sound, obj);
+/* 126 */ break;
+/* */ case 1033:
+/* 128 */ rv = intel33(sound, obj);
+/* 129 */ break;
+/* */ case 2000:
+/* 131 */ rv = realAudio0(sound, obj);
+/* 132 */ break;
+/* */ case 2010:
+/* 134 */ rv = realAudio10(sound, obj);
+/* 135 */ break;
+/* */ case 2011:
+/* 137 */ rv = realAudio11(sound, obj);
+/* 138 */ break;
+/* */ default:
+/* 140 */ rv = error(sound, obj);
+/* */ }
+/* */
+/* 143 */ return rv;
+/* */ }
+/* */
+/* */ private Object error(Sound sound, Object obj) {
+/* 147 */ debugOut(2, "Unknown state in SoundState " + sound.state);
+/* 148 */ return null;
+/* */ }
+/* */
+/* 151 */ private static URL dummy = URL.make("home:dummy.wav");
+/* */
+/* */ private Object start(Sound sound, Object obj) {
+/* 154 */ debugOut(6, "Entering SoundState ");
+/* 155 */ assert (sound.backgroundState == 1);
+/* */
+/* 157 */ if (sound.isRealAudio(sound.getURL())) {
+/* 158 */ sound.changeState(2000);
+/* */ }
+/* */ else {
+/* 161 */ sound.changeState(1000);
+/* */ }
+/* 163 */ sound.doState(null);
+/* 164 */ return null;
+/* */ }
+/* */
+/* */ private Object intel0(Sound sound, Object obj) {
+/* 168 */ debugOut(6, "Entering intel0 ");
+/* 169 */ assert (sound.backgroundState == 1);
+/* */
+/* */
+/* 172 */ if (!SoundResource.instance().syncLock(1)) {
+/* 173 */ return null;
+/* */ }
+/* 175 */ if (!sound.getURL().isRemote()) {
+/* 176 */ sound.changeState(1010);
+/* 177 */ BackgroundLoader.get(sound, sound.getURL());
+/* 178 */ return null;
+/* */ }
+/* 180 */ sound.cachedFile = Cache.getFile(sound.getURL());
+/* 181 */ if (sound.cachedFile.done()) {
+/* 182 */ sound.ensureClosure();
+/* 183 */ sound.changeState(1020);
+/* 184 */ BackgroundLoader.get(sound, sound.getURL());
+/* 185 */ return null;
+/* */ }
+/* */
+/* */
+/* 189 */ sound.cachedFile.finalize();
+/* 190 */ sound.cachedFile = null;
+/* */
+/* 192 */ sound.changeState(1030);
+/* 193 */ BackgroundLoader.get(sound, dummy);
+/* 194 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object intel10(Sound sound, Object localName)
+/* */ {
+/* 201 */ assert (sound.backgroundState == 2);
+/* 202 */ assert (localName != null);
+/* */
+/* 204 */ SoundResource.instance().asyncLock();
+/* */
+/* 206 */ sound.changeState(1011);
+/* */
+/* 208 */ if (sound.openPlayer((URL)localName)) {
+/* 209 */ return localName;
+/* */ }
+/* */
+/* 212 */ debugOut(2, "intel10: couldn't open sound " + sound.getURL());
+/* 213 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ private Object intel11(Sound sound, Object obj)
+/* */ {
+/* 222 */ debugOut(6, "Entering intel11 ");
+/* 223 */ assert (sound.backgroundState == 1);
+/* 224 */ if (obj != null) {
+/* 225 */ if (sound.updateSound()) {
+/* 226 */ sound.player.start(sound.getRepeat());
+/* */ }
+/* */ else
+/* 229 */ sound.closePlayer();
+/* */ }
+/* 231 */ sound.changeState(0);
+/* 232 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object intel20(Sound sound, Object obj)
+/* */ {
+/* 239 */ debugOut(6, "Entering intel20 ");
+/* 240 */ assert (sound.backgroundState == 2);
+/* */
+/* 242 */ SoundResource.instance().asyncLock();
+/* */
+/* 244 */ if (sound.openPlayer((URL)obj)) {
+/* 245 */ sound.changeState(1021);
+/* 246 */ return obj;
+/* */ }
+/* */
+/* 249 */ debugOut(2, "intel20: couldn't open player on sound " +
+/* 250 */ sound.getURL());
+/* 251 */ sound.changeState(1021);
+/* 252 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ private Object intel21(Sound sound, Object obj)
+/* */ {
+/* 260 */ debugOut(6, "Entering intel21 ");
+/* 261 */ assert (sound.backgroundState == 1);
+/* */
+/* 263 */ if (obj == null) {
+/* 264 */ sound.unlockCache();
+/* */ }
+/* 266 */ else if (sound.updateSound()) {
+/* 267 */ debugOut(6, "intel21 starting sound");
+/* 268 */ sound.player.start(sound.getRepeat());
+/* */ }
+/* */ else {
+/* 271 */ debugOut(6, "intel21 closing player");
+/* 272 */ sound.closePlayer();
+/* */ }
+/* */
+/* 275 */ sound.changeState(0);
+/* 276 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object intel30(Sound sound, Object obj)
+/* */ {
+/* 283 */ debugOut(6, "Entering intel30 ");
+/* 284 */ assert (sound.backgroundState == 2);
+/* */
+/* 286 */ SoundResource.instance().asyncLock();
+/* */
+/* 288 */ if (sound.openPlayer(dummy)) {
+/* 289 */ sound.changeState(1031);
+/* 290 */ return obj;
+/* */ }
+/* */
+/* 293 */ debugOut(2, "intel30: couldn't open player on file " +
+/* 294 */ sound.getURL());
+/* 295 */ sound.changeState(1031);
+/* 296 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ private Object intel31(Sound sound, Object obj)
+/* */ {
+/* 304 */ debugOut(6, "Entering intel31 ");
+/* 305 */ assert (sound.backgroundState == 1);
+/* */
+/* 307 */ if (obj == null) {
+/* 308 */ sound.changeState(0);
+/* */ }
+/* 310 */ else if (sound.updateSound()) {
+/* 311 */ sound.player.start(1);
+/* 312 */ sound.changeState(1032);
+/* 313 */ BackgroundLoader.get(sound, sound.getURL());
+/* */ }
+/* */ else {
+/* 316 */ sound.closePlayer();
+/* 317 */ sound.changeState(0);
+/* */ }
+/* */
+/* 320 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object intel32(Sound sound, Object obj)
+/* */ {
+/* 327 */ debugOut(6, "Entering intel32 ");
+/* 328 */ assert (sound.backgroundState == 2);
+/* */
+/* 330 */ sound.changeState(1033);
+/* 331 */ return obj;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object intel33(Sound sound, Object obj)
+/* */ {
+/* 338 */ debugOut(6, "Entering intel33 ");
+/* 339 */ assert (sound.backgroundState == 1);
+/* */
+/* 341 */ if ((obj != null) && (sound.playAfterLoading)) {
+/* 342 */ sound.closePlayer();
+/* */
+/* */
+/* 345 */ sound.changeState(1000);
+/* 346 */ sound.doState(obj);
+/* */ }
+/* */ else {
+/* 349 */ sound.changeState(0); }
+/* 350 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object realAudio0(Sound sound, Object obj)
+/* */ {
+/* 357 */ debugOut(6, "Entering RealAudio0 ");
+/* 358 */ assert (sound.backgroundState == 1);
+/* */
+/* */
+/* 361 */ if (!SoundResource.instance().syncLock(2)) {
+/* 362 */ return null;
+/* */ }
+/* */
+/* 365 */ sound.changeState(2010);
+/* 366 */ BackgroundLoader.get(sound, dummy);
+/* 367 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object realAudio10(Sound sound, Object obj)
+/* */ {
+/* 374 */ debugOut(6, "Entering realAudio10 ");
+/* 375 */ assert (sound.backgroundState == 2);
+/* */
+/* 377 */ SoundResource.instance().asyncLock();
+/* */
+/* 379 */ if (sound.openPlayer(sound.getURL())) {
+/* 380 */ sound.changeState(2011);
+/* 381 */ return sound;
+/* */ }
+/* */
+/* 384 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */ private Object realAudio11(Sound sound, Object obj)
+/* */ {
+/* 391 */ debugOut(6, "Entering realAudio11 ");
+/* 392 */ assert (sound.backgroundState == 1);
+/* */
+/* 394 */ if (obj != null) {
+/* 395 */ if (sound.updateSound()) {
+/* 396 */ sound.player.start(sound.getRepeat());
+/* */ }
+/* */ else {
+/* 399 */ sound.closePlayer();
+/* */ }
+/* */ }
+/* 402 */ sound.changeState(0);
+/* 403 */ return null;
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\SoundState.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file