From 24c6ed64726c5b5dec63bb452146cf5c90089f4b Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Sun, 18 Jun 2023 04:04:47 +0300 Subject: [PATCH] Delete multisample code --- src/nmania/MultiSample.java | 87 ------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 src/nmania/MultiSample.java diff --git a/src/nmania/MultiSample.java b/src/nmania/MultiSample.java deleted file mode 100644 index d78988e2..00000000 --- a/src/nmania/MultiSample.java +++ /dev/null @@ -1,87 +0,0 @@ -package nmania; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import javax.microedition.media.Manager; -import javax.microedition.media.MediaException; -import javax.microedition.media.Player; - -/** - * Zero-allocation (in theory) pool of samples. - * - * @author Feodor0090 - * - */ -public final class MultiSample { - - /** - * Creates the pool. - * - * @param local Is it inside JAR package? - * @param file File name. - * @param type MIME type. - * @param count Count of player to prepare. - * @throws IOException - * @throws MediaException - */ - public MultiSample(boolean local, String file, String type, int count) throws IOException, MediaException { - poolSize = count; - pool = new Player[count]; - streams = new ByteArrayInputStream[count]; - ByteArrayOutputStream os = new ByteArrayOutputStream(); - InputStream data; - if (local) { - data = getClass().getResourceAsStream(file); - } else { - throw new IllegalArgumentException("Remote samples are not supported yet!"); - } - byte[] buf = new byte[2048]; - int r; - while ((r = data.read(buf)) != -1) { - os.write(buf, 0, r); - } - raw = os.toByteArray(); - for (int i = 0; i < count; i++) { - streams[i] = new ByteArrayInputStream(raw); - Player player; - player = Manager.createPlayer(streams[i], type); - player.realize(); - player.prefetch(); - pool[i] = player; - } - } - - private byte[] raw; - private final ByteArrayInputStream[] streams; - private final Player[] pool; - private final int poolSize; - private int next; - - public final void Play() { - try { - pool[next].setMediaTime(0); - pool[next].start(); - } catch (MediaException e) { - } - next++; - if (next >= poolSize) - next = 0; - } - - public final void Dispose() { - for (int i = 0; i < poolSize; i++) { - pool[i].deallocate(); - pool[i].close(); - pool[i] = null; - try { - streams[i].close(); - } catch (IOException e) { - } - streams[i] = null; - } - raw = null; - } -}