aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java27
2 files changed, 25 insertions, 5 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
index 51724d240..3e4d589f3 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -545,6 +545,9 @@ public interface GLMediaPlayer extends TextureSequence {
/** Returns the audio volume. */
public float getAudioVolume();
+ /** Returns true if audio is muted, i.e. {@link #setAudioVolume(float)} to zero. */
+ public boolean isAudioMuted();
+
/**
* Starts or resumes the <i>StreamWorker</i> decoding thread.
* <p>
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 3ca5f9aac..8859d537e 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -59,6 +59,7 @@ import com.jogamp.common.util.InterruptSource;
import com.jogamp.common.util.LFRingbuffer;
import com.jogamp.common.util.Ringbuffer;
import com.jogamp.common.util.WorkerThread;
+import com.jogamp.math.FloatUtil;
import com.jogamp.opengl.GLExtensions;
import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.glsl.ShaderCode;
@@ -533,6 +534,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
getAudioVolumeImpl();
return audioVolume;
}
+
+ @Override
+ public boolean isAudioMuted() {
+ return FloatUtil.isZero(audioVolume);
+ }
+
/**
* Override if not using AudioSink, or AudioSink's {@link AudioSink#getVolume()} is not sufficient!
*/
@@ -542,21 +549,30 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
}
+ 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 boolean setAudioVolume(float v) {
synchronized( stateLock ) {
final float preVolume = audioVolume;
boolean res = false;
+ v = clipAudioVolume(v);
if(State.Uninitialized != state ) {
- if( Math.abs(v) < 0.01f ) {
- v = 0.0f;
- } else if( Math.abs(1.0f - v) < 0.01f ) {
- v = 1.0f;
- }
if( setAudioVolumeImpl(v) ) {
audioVolume = v;
res = true;
}
+ } else {
+ // earmark ..
+ audioVolume = v;
+ res = true;
}
if(DEBUG) { System.err.println("setAudioVolume("+v+"): "+state+", "+preVolume+" -> "+audioVolume+", "+toString()); }
return res;
@@ -682,6 +698,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
removeAllTextureFrames(gl);
if( State.Uninitialized != state ) {
initGLImpl(gl);
+ setAudioVolume( audioVolume ); // update volume
if(DEBUG) {
System.err.println("initGLImpl.X "+this);
}