Create all controlled components with an event bus.
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / data / filter / LameMp3Encoder.java
index 2436b52..77df8aa 100644 (file)
@@ -19,10 +19,11 @@ package net.pterodactylus.sonitus.data.filter;
 
 import java.util.Arrays;
 
-import net.pterodactylus.sonitus.data.Format;
+import net.pterodactylus.sonitus.data.Metadata;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
+import com.google.common.eventbus.EventBus;
 
 /**
  * {@link ExternalMp3Encoder} implementation that uses LAME to encode MP3s.
@@ -66,30 +67,36 @@ public class LameMp3Encoder extends ExternalMp3Encoder {
        /**
         * Creates a new LAME MP3 encoder.
         *
+        * @param eventBus
+        *              The event bus
         * @param binary
         *              The location of the binary
         * @param preset
         *              The preset to use
         */
-       public LameMp3Encoder(String binary, Preset preset) {
-               this(binary, preset, -1);
+       public LameMp3Encoder(EventBus eventBus, String binary, Preset preset) {
+               this(eventBus, binary, preset, -1);
        }
 
        /**
         * Creates a new LAME MP3 encoder.
         *
+        * @param eventBus
+        *              The event bus
         * @param binary
         *              The location of the binary
         * @param bitrate
         *              The bitrate to encode to (in kbps)
         */
-       public LameMp3Encoder(String binary, int bitrate) {
-               this(binary, null, bitrate);
+       public LameMp3Encoder(EventBus eventBus, String binary, int bitrate) {
+               this(eventBus, binary, null, bitrate);
        }
 
        /**
         * Creates a new LAME MP3 encoder.
         *
+        * @param eventBus
+        *              The event bus
         * @param binary
         *              The location of the binary
         * @param preset
@@ -97,7 +104,8 @@ public class LameMp3Encoder extends ExternalMp3Encoder {
         * @param bitrate
         *              The bitrate to encode to (in kbps)
         */
-       private LameMp3Encoder(String binary, Preset preset, int bitrate) {
+       private LameMp3Encoder(EventBus eventBus, String binary, Preset preset, int bitrate) {
+               super(eventBus, "LAME Encoder");
                this.binary = binary;
                this.preset = Optional.fromNullable(preset);
                this.bitrate = (bitrate < 0) ? Optional.<Integer>absent() : Optional.<Integer>of(bitrate);
@@ -133,15 +141,15 @@ public class LameMp3Encoder extends ExternalMp3Encoder {
        //
 
        @Override
-       protected String binary(Format format) {
+       protected String binary(Metadata metadata) {
                return binary;
        }
 
        @Override
-       protected Iterable<String> parameters(Format format) {
-               ImmutableList.Builder parameters = ImmutableList.builder();
+       protected Iterable<String> parameters(Metadata metadata) {
+               ImmutableList.Builder<String> parameters = ImmutableList.builder();
                parameters.add("-r");
-               parameters.add("-s").add(String.valueOf(format.frequency() / 1000.0));
+               parameters.add("-s").add(String.valueOf(metadata.frequency() / 1000.0));
                if (swapBytes) {
                        parameters.add("-x");
                }