diff options
author | Sven Gothel <[email protected]> | 2023-05-23 02:13:08 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-23 02:13:08 +0200 |
commit | b294b6e4f9a3dc24bcdce28f0a9c45eda8755f1f (patch) | |
tree | 1b7e5473ed3786c41419b7d1e6ce2f8b7fe8e9d3 /src/jogl/classes/jogamp/opengl/util | |
parent | 55fb624ac388a88c068bd9f9e7cc3164458d6201 (diff) |
GLMediaPlayer: Add setAudioChannelLimit(..), correlating with AudioSink.setChannelLimit() ..
May be utilized to enforce 1 channel (mono) downsampling
in combination with JOAL/OpenAL to experience spatial 3D position effects.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 7 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 9e390319a..eb4ef5713 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -96,6 +96,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private int textureInternalFormat; private int textureType; private int texUnit; + private int userMaxChannels = -1; // not set private int textureFragmentShaderHashCode; @@ -248,6 +249,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int[] getTextureWrapST() { return texWrapST; } @Override + public final void setAudioChannelLimit(final int cc) { + userMaxChannels = Math.min(8, Math.max(1, cc)); + } + protected int getAudioChannelLimit() { return userMaxChannels; } + + @Override public String getRequiredExtensionsShaderStub() { if(GLES2.GL_TEXTURE_EXTERNAL_OES == textureTarget) { return ShaderCode.createExtensionDirective(GLExtensions.OES_EGL_image_external, ShaderCode.ENABLE); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index d6bbbdc5d..7b86b012d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -346,6 +346,12 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } else { audioSink = AudioSinkFactory.createDefault(FFMPEGMediaPlayer.class.getClassLoader()); } + { + final int audioChannelLimit = getAudioChannelLimit(); + if( audioChannelLimit >= 1 ) { + audioSink.setChannelLimit(audioChannelLimit); + } + } final AudioFormat preferredAudioFormat = audioSink.getPreferredFormat(); if(DEBUG) { System.err.println("initStream: p2 aid "+aid+", preferred "+preferredAudioFormat+" on "+audioSink+", "+this); @@ -385,7 +391,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } else { resStreamLocS = streamLocS; } - final int aMaxChannelCount = audioSink.getMaxSupportedChannels(); + final int aMaxChannelCount = preferredAudioFormat.channelCount; final int aPrefSampleRate = preferredAudioFormat.sampleRate; // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc if(DEBUG) { |