From 3b9dfb3c76a0004a5c7f7836214a1ed71a264683 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sat, 22 Jan 2022 17:03:21 +0100 Subject: [PATCH] Fix vorbis chapter parsing --- .../parser/media/vorbis/VorbisCommentReader.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/parser/media/src/main/java/de/danoeh/antennapod/parser/media/vorbis/VorbisCommentReader.java b/parser/media/src/main/java/de/danoeh/antennapod/parser/media/vorbis/VorbisCommentReader.java index b4f87bd70..607172531 100644 --- a/parser/media/src/main/java/de/danoeh/antennapod/parser/media/vorbis/VorbisCommentReader.java +++ b/parser/media/src/main/java/de/danoeh/antennapod/parser/media/vorbis/VorbisCommentReader.java @@ -41,7 +41,7 @@ public abstract class VorbisCommentReader { public void readInputStream(InputStream input) throws VorbisCommentReaderException { try { - findIdentificationHeader(input); + skipIdentificationHeader(input); onVorbisCommentFound(); findOggPage(input); findCommentHeader(input); @@ -101,21 +101,20 @@ public abstract class VorbisCommentReader { /** * Looks for an identification header in the first page of the file. If an - * identification header is found, it will be skipped completely and the - * method will return true, otherwise false. + * identification header is found, it will be skipped completely */ - private void findIdentificationHeader(InputStream input) throws IOException { + private void skipIdentificationHeader(InputStream input) throws IOException { byte[] buffer = new byte[FIRST_OPUS_PAGE_LENGTH]; IOUtils.readFully(input, buffer); final byte[] oggIdentificationHeader = new byte[]{ PACKET_TYPE_IDENTIFICATION, 'v', 'o', 'r', 'b', 'i', 's' }; for (int i = 6; i < buffer.length; i++) { if (bufferMatches(buffer, oggIdentificationHeader, i)) { IOUtils.skip(input, FIRST_OGG_PAGE_LENGTH - FIRST_OPUS_PAGE_LENGTH); + return; } else if (bufferMatches(buffer, "OpusHead".getBytes(), i)) { return; } } - throw new IOException("No identification header found"); } private void findCommentHeader(InputStream input) throws IOException {