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); } }