From: David ‘Bombe’ Roden Date: Tue, 28 May 2013 10:59:42 +0000 (+0200) Subject: Fix metadata updating after a reset. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;ds=inline;h=43921b29019c0dbdd61ea5def56b0d3edde027cb;p=sonitus.git Fix metadata updating after a reset. --- 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 6f31830..b5a081d 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java @@ -100,20 +100,30 @@ public class TimeCounterFilter extends DummyFilter { @Override public void metadataUpdated(Metadata metadata) { - super.metadataUpdated(metadata); parentMetadata.set(metadata); if (resetOnMetadataUpdate) { reset(); } + updateTimestamp(); } @Override public void process(byte[] buffer) throws IOException { super.process(buffer); counter.getAndAdd(buffer.length); + updateTimestamp(); + } + + // + // PRIVATE METHODS + // + + /** Updates the timestamp in the metadata. */ + private void updateTimestamp() { long timestamp = getMillis() / 1000; if (lastTimestamp.get() != timestamp) { super.metadataUpdated(parentMetadata.get().title(String.format("%s (%02d:%02d)", parentMetadata.get().title(), timestamp / 60, timestamp % 60))); + lastTimestamp.set(timestamp); } }