summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/MCIThread.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/MCIThread.java')
-rw-r--r--NET/worlds/scape/MCIThread.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/NET/worlds/scape/MCIThread.java b/NET/worlds/scape/MCIThread.java
new file mode 100644
index 0000000..e63518a
--- /dev/null
+++ b/NET/worlds/scape/MCIThread.java
@@ -0,0 +1,44 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Main;
+import NET.worlds.console.MainCallback;
+import NET.worlds.console.MainTerminalCallback;
+import java.util.Vector;
+
+class MCIThread implements MainCallback, MainTerminalCallback {
+ private Vector queue = new Vector();
+ private int frameNum;
+
+ public MCIThread() {
+ Main.register(this);
+ }
+
+ public synchronized void pushCommand(MCISoundCommand c) {
+ this.queue.addElement(c);
+ c.onQueue(true);
+ c.frameNum = this.frameNum + 2;
+ }
+
+ @Override
+ public synchronized void mainCallback() {
+ this.frameNum++;
+
+ while (this.queue.size() > 0) {
+ MCISoundCommand command = (MCISoundCommand)this.queue.elementAt(0);
+ if (command.frameNum > this.frameNum) {
+ return;
+ }
+
+ command.onQueue(false);
+ this.queue.removeElementAt(0);
+ command.run();
+ }
+ }
+
+ @Override
+ public synchronized void terminalCallback() {
+ MCISoundPlayer.shutdown();
+ ASFSoundPlayer.shutdown();
+ Main.unregister(this);
+ }
+}