From 21079539c1f81bae9df328e6487e4d4d174b0b51 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 16 Oct 2023 03:57:26 +0200 Subject: ALAudioSink: Use clipAudioVolume(..) function for clarity --- src/java/com/jogamp/openal/util/ALAudioSink.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/java/com/jogamp/openal/util/ALAudioSink.java b/src/java/com/jogamp/openal/util/ALAudioSink.java index 0123cc9..22695ae 100644 --- a/src/java/com/jogamp/openal/util/ALAudioSink.java +++ b/src/java/com/jogamp/openal/util/ALAudioSink.java @@ -1178,6 +1178,14 @@ public final class ALAudioSink implements AudioSink { return volume; } + private static final float clipAudioVolume(final float v) { + if( v < 0.01f ) { + return 0.0f; + } else if( Math.abs(1.0f - v) < 0.01f ) { + return 1.0f; + } + return v; + } @Override public final boolean setVolume(float v) { if( !available || null == chosenFormat ) { @@ -1185,11 +1193,7 @@ public final class ALAudioSink implements AudioSink { } makeCurrent(true /* throw */); try { - if( Math.abs(v) < 0.01f ) { - v = 0.0f; - } else if( Math.abs(1.0f - v) < 0.01f ) { - v = 1.0f; - } + v = clipAudioVolume(v); if( 0.0f <= v && v <= 1.0f ) { // OpenAL limits volume = v; alSource.setGain(v); -- cgit v1.2.3