Create all controlled components with an event bus.
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / data / filter / OggVorbisDecoder.java
index 2cd9035..d98abe1 100644 (file)
 
 package net.pterodactylus.sonitus.data.filter;
 
-import net.pterodactylus.sonitus.data.ConnectException;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.IOException;
+
 import net.pterodactylus.sonitus.data.Metadata;
-import net.pterodactylus.sonitus.data.Source;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import com.google.common.eventbus.EventBus;
 
 /**
  * Ogg Vorbis decoder that uses {@code oggdec} (from the {@code vorbis-tools}
@@ -41,10 +44,13 @@ public class OggVorbisDecoder extends ExternalFilter {
        /**
         * Creates a new Ogg Vorbis decoder.
         *
+        * @param eventBus
+        *              The event bus
         * @param binary
         *              The location of the binary
         */
-       public OggVorbisDecoder(String binary) {
+       public OggVorbisDecoder(EventBus eventBus, String binary) {
+               super(eventBus, "Ogg Vorbis Decoder");
                this.binary = binary;
        }
 
@@ -70,11 +76,11 @@ public class OggVorbisDecoder extends ExternalFilter {
        }
 
        @Override
-       public void connect(Source source) throws ConnectException {
-               Preconditions.checkNotNull(source, "source must not be null");
-               Preconditions.checkArgument(source.metadata().encoding().equalsIgnoreCase("Vorbis"), "source must be Vorbis-encoded");
+       public void open(Metadata metadata) throws IOException {
+               checkNotNull(metadata, "metadata must not be null");
+               checkArgument(metadata.encoding().equalsIgnoreCase("Vorbis"), "source must be Vorbis-encoded");
 
-               super.connect(source);
+               super.open(metadata);
        }
 
        //