diff options
author | Sven Gothel <[email protected]> | 2023-10-16 03:57:26 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-10-16 03:57:26 +0200 |
commit | 21079539c1f81bae9df328e6487e4d4d174b0b51 (patch) | |
tree | 885f4c47d7bb6c9a5d5cb1cd86b9ad8592a99075 | |
parent | 12029f1ec1d8afa576e1ac61655f318cc37c1d16 (diff) |
ALAudioSink: Use clipAudioVolume(..) function for clarity
-rw-r--r-- | src/java/com/jogamp/openal/util/ALAudioSink.java | 14 |
1 files 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); |