From fcc802838a7d92f4256685411a09a9b62a04c34e Mon Sep 17 00:00:00 2001 From: wuhelong Date: Wed, 23 Nov 2022 10:40:23 +0800 Subject: [PATCH 1/2] Fixed maxPacketsPerPage not being applied when saving OpusFile --- core/src/main/java/org/gagravarr/opus/OpusFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/org/gagravarr/opus/OpusFile.java b/core/src/main/java/org/gagravarr/opus/OpusFile.java index 6ddc4be..c51d326 100644 --- a/core/src/main/java/org/gagravarr/opus/OpusFile.java +++ b/core/src/main/java/org/gagravarr/opus/OpusFile.java @@ -280,6 +280,7 @@ public void close() throws IOException { } } if (doneFlush) { + doneFlush = false; pageSize = 0; pageSamples = 0; } From 8b83f3f57330b9d52397142bf2bb25a6f7365eab Mon Sep 17 00:00:00 2001 From: wuhelong Date: Wed, 23 Nov 2022 11:25:44 +0800 Subject: [PATCH 2/2] Fixed the problem that the Granule Position on the last page was not updated when saving the OpusFile --- core/src/main/java/org/gagravarr/opus/OpusFile.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/gagravarr/opus/OpusFile.java b/core/src/main/java/org/gagravarr/opus/OpusFile.java index c51d326..1f4d21a 100644 --- a/core/src/main/java/org/gagravarr/opus/OpusFile.java +++ b/core/src/main/java/org/gagravarr/opus/OpusFile.java @@ -233,7 +233,7 @@ public void close() throws IOException { final int packetsSize = packets.size(); final int maxPacketsPerPage = this.maxPacketsPerPage; - OpusAudioData packet; + OpusAudioData packet = null; int pageSize = 0; int pageSamples = 0; long lastGranule = 0; @@ -285,7 +285,8 @@ public void close() throws IOException { pageSamples = 0; } } - + if (packet != null) + w.setGranulePosition(packet.getGranulePosition()); w.close(); w = null; ogg.close();