From 00af65503a2076371291ce8e019da2546458bdac Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Mar 2013 18:26:05 +0100 Subject: [PATCH] =?utf8?q?Make=20setting=20the=20=E2=80=9CswapBytes?= =?utf8?q?=E2=80=9D=20switch=20optional.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sonitus/data/filter/LameMp3Decoder.java | 15 ++++++++-- .../sonitus/data/filter/LameMp3Encoder.java | 35 ++++++++++++---------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java index aae01fe..fb7bf94 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java @@ -32,20 +32,29 @@ public class LameMp3Decoder extends ExternalMp3Decoder { private final String binary; /** Whether to swap bytes in the decoded output. */ - private final boolean swapBytes; + private boolean swapBytes; /** * Creates a new LAME MP3 decoder. * * @param binary * The location of the binary + */ + public LameMp3Decoder(String binary) { + this.binary = binary; + } + + /** + * Sets whether to swap bytes on the decoded output. + * * @param swapBytes * {@code true} to swap the decoded bytes, {@code false} to use platform * endianness + * @return This MP3 decoder */ - public LameMp3Decoder(String binary, boolean swapBytes) { - this.binary = binary; + public LameMp3Decoder swapBytes(boolean swapBytes) { this.swapBytes = swapBytes; + return this; } // diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java index 66abb10..2436b52 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java @@ -52,7 +52,7 @@ public class LameMp3Encoder extends ExternalMp3Encoder { private final String binary; /** Whether to swap bytes in the input. */ - private final boolean swapBytes; + private boolean swapBytes; /** The preset to use. */ private final Optional preset; @@ -68,14 +68,11 @@ public class LameMp3Encoder extends ExternalMp3Encoder { * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap bytes in the input, {@code false} to use platform - * endianness * @param preset * The preset to use */ - public LameMp3Encoder(String binary, boolean swapBytes, Preset preset) { - this(binary, swapBytes, preset, -1); + public LameMp3Encoder(String binary, Preset preset) { + this(binary, preset, -1); } /** @@ -83,14 +80,11 @@ public class LameMp3Encoder extends ExternalMp3Encoder { * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap bytes in the input, {@code false} to use platform - * endianness * @param bitrate * The bitrate to encode to (in kbps) */ - public LameMp3Encoder(String binary, boolean swapBytes, int bitrate) { - this(binary, swapBytes, null, bitrate); + public LameMp3Encoder(String binary, int bitrate) { + this(binary, null, bitrate); } /** @@ -98,22 +92,31 @@ public class LameMp3Encoder extends ExternalMp3Encoder { * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap bytes in the input, {@code false} to use platform - * endianness * @param preset * The preset to use * @param bitrate * The bitrate to encode to (in kbps) */ - private LameMp3Encoder(String binary, boolean swapBytes, Preset preset, int bitrate) { + private LameMp3Encoder(String binary, Preset preset, int bitrate) { this.binary = binary; - this.swapBytes = swapBytes; this.preset = Optional.fromNullable(preset); this.bitrate = (bitrate < 0) ? Optional.absent() : Optional.of(bitrate); } /** + * Sets whether to swap bytes on the input to encode + * + * @param swapBytes + * {@code true} to swap the input bytes, {@code false} to use platform + * endianness + * @return This MP3 encoder + */ + public LameMp3Encoder swapBytes(boolean swapBytes) { + this.swapBytes = swapBytes; + return this; + } + + /** * Sets whether to use highest quality encoding. * * @param hq -- 2.7.4