Rename “Controlled” to “ControlledComponent.”
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / data / Sink.java
1 package net.pterodactylus.sonitus.data;
2
3 import java.io.IOException;
4
5 /**
6  * A sink is a destination for audio data. It can be played on speakers, it can
7  * be written to a file, or it can be sent to a remote streaming server.
8  *
9  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
10  */
11 public interface Sink extends ControlledComponent {
12
13         /**
14          * Opens this sink using the format parameters of the given metadata.
15          *
16          * @param metadata
17          *              The metadata of the stream
18          * @throws IOException
19          *              if an I/O error occurs
20          */
21         void open(Metadata metadata) throws IOException;
22
23         /** Closes this sink. */
24         void close();
25
26         /**
27          * Processes the given buffer of data.
28          *
29          * @param buffer
30          *              The data to process
31          * @throws IOException
32          *              if an I/O error occurs
33          */
34         void process(byte[] buffer) throws IOException;
35
36         /**
37          * Notifies the sink that the metadata of the audio stream has changed. This
38          * method should return as fast as possible, i.e. every heavy lifting should be
39          * done from another thread.
40          *
41          * @param metadata
42          *              The new metadata
43          */
44         void metadataUpdated(Metadata metadata);
45
46 }