From 43921b29019c0dbdd61ea5def56b0d3edde027cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 28 May 2013 12:59:42 +0200 Subject: [PATCH] Fix metadata updating after a reset. --- .../pterodactylus/sonitus/data/filter/TimeCounterFilter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); } } -- 2.7.4