X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FTimeCounterFilter.java;h=9b65670a138413f21532d1df37ca57d063237550;hb=7d208293e164d995e319266ea28fd5be63c1a737;hp=0eb82818325ab9f65b7e0e73b01c45b51dd135c9;hpb=1b5da82617f1ba7e569c63daf4fb981d0fd7f406;p=sonitus.git diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java b/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java index 0eb8281..9b65670 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java @@ -22,12 +22,13 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import net.pterodactylus.sonitus.data.AbstractFilter; +import net.pterodactylus.sonitus.data.DataPacket; import net.pterodactylus.sonitus.data.Filter; import net.pterodactylus.sonitus.data.Metadata; /** * {@link Filter} implementation that uses the number of bytes that have been - * {@link #process(byte[]) processed} together with the {@link Metadata} to + * {@link #process(DataPacket) processed} together with the {@link Metadata} to * calculate how long a source is already playing. * * @author David ‘Bombe’ Roden @@ -77,7 +78,7 @@ public class TimeCounterFilter extends AbstractFilter implements Filter { /** * Returns the number of milliseconds worth of data that has been passed into - * {@link #process(byte[])}. If no metadata has yet been set, {@code 0} is + * {@link #process(DataPacket)}. If no metadata has yet been set, {@code 0} is * returned. * * @return The number of milliseconds the current source is already playing @@ -109,9 +110,9 @@ public class TimeCounterFilter extends AbstractFilter implements Filter { } @Override - public void process(byte[] buffer) throws IOException { - super.process(buffer); - counter.getAndAdd(buffer.length); + public void process(DataPacket dataPacket) throws IOException { + super.process(dataPacket); + counter.getAndAdd(dataPacket.buffer().length); updateTimestamp(false); } @@ -123,7 +124,7 @@ public class TimeCounterFilter extends AbstractFilter implements Filter { private void updateTimestamp(boolean now) { long timestamp = getMillis() / 1000; if (now || (lastTimestamp.get() != timestamp)) { - super.metadataUpdated(parentMetadata.get().comment(String.format("%s%02d:%02d", (timestamp >= 3600) ? String.format("%d:", timestamp / 3600) : "" , (timestamp % 3600) / 60, timestamp % 60))); + super.metadataUpdated(parentMetadata.get().comment(String.format("%s%02d:%02d", (timestamp >= 3600) ? String.format("%d:", timestamp / 3600) : "", (timestamp % 3600) / 60, timestamp % 60))); lastTimestamp.set(timestamp); } }