From: David ‘Bombe’ Roden Date: Sun, 2 Jun 2013 00:08:41 +0000 (+0200) Subject: Write the first bytes to the buffer correctly. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=aeb4004e3483f17e79e9c12f0f238db58d3eb09e;p=sonitus.git 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. --- 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; }