From: David ‘Bombe’ Roden Date: Mon, 3 Jun 2013 20:27:50 +0000 (+0200) Subject: Add FLAC identifier and fix comments. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=49aade1295ee9893f2561d8d2ef0812e917087d1;p=sonitus.git Add FLAC identifier and fix comments. --- diff --git a/src/main/java/net/pterodactylus/sonitus/io/IdentifyingInputStream.java b/src/main/java/net/pterodactylus/sonitus/io/IdentifyingInputStream.java index 6035cbf..3a4a9fb 100644 --- a/src/main/java/net/pterodactylus/sonitus/io/IdentifyingInputStream.java +++ b/src/main/java/net/pterodactylus/sonitus/io/IdentifyingInputStream.java @@ -84,8 +84,19 @@ public class IdentifyingInputStream extends FilterInputStream { /* remember everything we read here. */ RememberingInputStream rememberingInputStream = new RememberingInputStream(inputStream); - /* try Ogg Vorbis first. */ + /* first, try formats with unambiguous layouts. */ try { + Optional metadata = FlacIdentifier.identify(rememberingInputStream); + if (metadata.isPresent()) { + return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), metadata.get())); + } + } catch (EOFException eofe1) { + /* ignore. */ + } + + /* try Ogg Vorbis next. */ + try { + rememberingInputStream = new RememberingInputStream(rememberingInputStream.remembered()); Optional metadata = OggVorbisIdentifier.identify(rememberingInputStream); if (metadata.isPresent()) { return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), metadata.get())); @@ -94,7 +105,7 @@ public class IdentifyingInputStream extends FilterInputStream { /* ignore. */ } - /* try MP3 now. */ + /* finally, try MP3. */ try { rememberingInputStream = new RememberingInputStream(rememberingInputStream.remembered()); InputStream limitedInputStream = ByteStreams.limit(rememberingInputStream, 1048576);