From bb934de70c5e94e4009f815e24c9c1187deb5229 Mon Sep 17 00:00:00 2001 From: Recrown Date: Mon, 15 Jan 2018 00:18:46 -0600 Subject: [PATCH] minor optimizations --- .../graphics/ui/components/Visualizer.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java index 8b03cb2..6748eb3 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java @@ -116,13 +116,14 @@ public class Visualizer extends Widget implements Disposable { buffer.rewind(); if (compareBuffer.compareTo(buffer) != 0) { bufferChanged(); + + + //Begin copying current buffer to the comparison buffer + compareBuffer.clear(); + compareBuffer.put(buffer); + compareBuffer.flip(); } - //Begin copying current buffer to the comparison buffer - compareBuffer.clear(); - compareBuffer.put(buffer); - compareBuffer.flip(); - //Reset buffer to proper position. buffer.position(originalPos); } @@ -134,11 +135,11 @@ public class Visualizer extends Widget implements Disposable { private int updateBufferPosition() { int pos = (int) ((alGetSourcef(sourceID, AL11.AL_SAMPLE_OFFSET))-buffer.limit()-mm.getChannelCount()*mm.getReadWindowSize()); - try { - readWindowIndex = mm.getPlaybackIndexPosition()-1; - buffer.position(pos); - } catch (IllegalArgumentException iae) { + readWindowIndex = mm.getPlaybackIndexPosition()-1; + if (pos < 0) { buffer.position(0); + } else { + buffer.position(pos); } return pos; }