2 * Sonitus - Source.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sonitus.data;
20 import java.io.EOFException;
21 import java.io.IOException;
24 * Defines an arbitrary media source. This can be almost anything; an MP3 file,
25 * a FastTracker module, or a decoded WAVE file.
27 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29 public interface Source {
32 * Returns the format of this source.
34 * @return The format of this source
39 * Retrieves the given name of bytes from this source. The source should always
40 * try to read as much data as was requested but is free to return a byte array
41 * with less elements that requested. However, the byte array will always be
42 * the same size as the data that was actually read, i.e. there are no excess
43 * elements in the returned array.
46 * The size of the buffer
47 * @return A buffer that contains the read data
48 * @throws EOFException
49 * if the end of the source was reached
51 * if an I/O error occurs
53 byte[] get(int bufferSize) throws EOFException, IOException;