From d33602f1921d7c12833cdfd144f7207de0fcc67b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 15 Mar 2013 06:58:40 +0100 Subject: [PATCH] Add source interface. --- .../net/pterodactylus/sonitus/data/Source.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/net/pterodactylus/sonitus/data/Source.java diff --git a/src/main/java/net/pterodactylus/sonitus/data/Source.java b/src/main/java/net/pterodactylus/sonitus/data/Source.java new file mode 100644 index 0000000..e75b920 --- /dev/null +++ b/src/main/java/net/pterodactylus/sonitus/data/Source.java @@ -0,0 +1,55 @@ +/* + * Sonitus - Source.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sonitus.data; + +import java.io.EOFException; +import java.io.IOException; + +/** + * Defines an arbitrary media source. This can be almost anything; an MP3 file, + * a FastTracker module, or a decoded WAVE file. + * + * @author David ‘Bombe’ Roden + */ +public interface Source { + + /** + * Returns the format of this source. + * + * @return The format of this source + */ + Format format(); + + /** + * Retrieves the given name of bytes from this source. The source should always + * try to read as much data as was requested but is free to return a byte array + * with less elements that requested. However, the byte array will always be + * the same size as the data that was actually read, i.e. there are no excess + * elements in the returned array. + * + * @param bufferSize + * The size of the buffer + * @return A buffer that contains the read data + * @throws EOFException + * if the end of the source was reached + * @throws IOException + * if an I/O error occurs + */ + byte[] get(int bufferSize) throws EOFException, IOException; + +} -- 2.7.4