From aeb4004e3483f17e79e9c12f0f238db58d3eb09e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 2 Jun 2013 02:08:41 +0200 Subject: [PATCH] Write the first bytes to the buffer correctly. buffer is used as a ring buffer so new bytes have to go in at the end. --- src/main/java/net/pterodactylus/sonitus/io/mp3/Parser.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/pterodactylus/sonitus/io/mp3/Parser.java b/src/main/java/net/pterodactylus/sonitus/io/mp3/Parser.java index 8a7e771..55165d8 100644 --- a/src/main/java/net/pterodactylus/sonitus/io/mp3/Parser.java +++ b/src/main/java/net/pterodactylus/sonitus/io/mp3/Parser.java @@ -53,16 +53,16 @@ public class Parser { */ public Parser(InputStream inputStream) throws IOException { this.inputStream = inputStream; - readFully(inputStream, buffer, 0, 3); - if ((buffer[0] == 'I') && (buffer[1] == 'D') && (buffer[2] == '3')) { - readFully(inputStream, buffer, 0, 3); + readFully(inputStream, buffer, 1, 3); + if ((buffer[1] == 'I') && (buffer[2] == 'D') && (buffer[3] == '3')) { + readFully(inputStream, buffer, 1, 3); byte[] lengthBuffer = new byte[4]; readFully(inputStream, lengthBuffer, 0, 4); int headerLength = (lengthBuffer[0] << 21) | (lengthBuffer[1] << 14) | (lengthBuffer[2] << 7) | lengthBuffer[3]; id3Tag = new byte[headerLength + 10]; - System.arraycopy(new byte[] { 'I', 'D', '3', buffer[0], buffer[1], buffer[2], lengthBuffer[0], lengthBuffer[1], lengthBuffer[2], lengthBuffer[3] }, 0, id3Tag, 0, 10); + System.arraycopy(new byte[] { 'I', 'D', '3', buffer[1], buffer[2], buffer[3], lengthBuffer[0], lengthBuffer[1], lengthBuffer[2], lengthBuffer[3] }, 0, id3Tag, 0, 10); readFully(inputStream, id3Tag, 10, headerLength); - readFully(inputStream, buffer, 0, 3); + readFully(inputStream, buffer, 1, 3); } else { id3Tag = null; } -- 2.7.4