Fix metadata updating after a reset.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 28 May 2013 10:59:42 +0000 (12:59 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 28 May 2013 10:59:42 +0000 (12:59 +0200)
src/main/java/net/pterodactylus/sonitus/data/filter/TimeCounterFilter.java

index 6f31830..b5a081d 100644 (file)
@@ -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);
                }
        }