From 49aade1295ee9893f2561d8d2ef0812e917087d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 3 Jun 2013 22:27:50 +0200 Subject: [PATCH] Add FLAC identifier and fix comments. --- .../pterodactylus/sonitus/io/IdentifyingInputStream.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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); -- 2.7.4