From 60a1f4b9b237c7319cb765ac1a9895cf4f31d3a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 28 May 2013 14:47:20 +0200 Subject: [PATCH] Update immediately if the metadata has been updated. --- .../net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 96b4052..1c53d55 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java @@ -104,14 +104,14 @@ public class TimeCounterFilter extends DummyFilter { if (resetOnMetadataUpdate) { reset(); } - updateTimestamp(); + updateTimestamp(true); } @Override public void process(byte[] buffer) throws IOException { super.process(buffer); counter.getAndAdd(buffer.length); - updateTimestamp(); + updateTimestamp(false); } // @@ -119,9 +119,9 @@ public class TimeCounterFilter extends DummyFilter { // /** Updates the timestamp in the metadata. */ - private void updateTimestamp() { + private void updateTimestamp(boolean now) { long timestamp = getMillis() / 1000; - if (lastTimestamp.get() != timestamp) { + if (now || (lastTimestamp.get() != timestamp)) { super.metadataUpdated(parentMetadata.get().comment(String.format("%02d:%02d", timestamp / 60, timestamp % 60))); lastTimestamp.set(timestamp); } -- 2.7.4