From 9c430c92257739730155df05f340fe144fd24098 Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Thu, 16 Jan 2025 01:10:46 +0000 Subject: [PATCH] 8336920: ArithmeticException in javax.sound.sampled.AudioInputStream Reviewed-by: azvegint, prr --- .../classes/com/sun/media/sound/SoftLinearResampler2.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java b/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java index 782bcc23d21d8..07108d9a393ed 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/SoftLinearResampler2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,10 @@ public void interpolate(float[] in, float[] in_offset, float in_end, int p_ix = (int) (ix * (1 << 15)); int p_ix_end = (int) (ix_end * (1 << 15)); int p_pitch = (int) (pitch * (1 << 15)); + if (p_pitch == 0) { + // If pitch falls below the minimum assume minimum pitch + p_pitch = 1; + } // Pitch needs to recalculated // to ensure no drift between p_ix and ix. pitch = p_pitch * (1f / (1 << 15));