From 32210a87c2d9b10e04a773fa1b86f8f543d83af0 Mon Sep 17 00:00:00 2001 From: Xerxes Rånby Date: Tue, 16 Jul 2013 11:56:37 +0200 Subject: FFMPEGMediaPlayer: Only instance ALAudioSink if JOAL is found on the classpath. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes Rånby --- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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 9c0c9bd94..806befe06 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -41,17 +41,16 @@ import javax.media.opengl.GLException; import java.util.Arrays; import java.util.Queue; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.opengl.util.GLPixelStorageModes; +import com.jogamp.opengl.util.av.GLMediaPlayerFactory; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.opengl.GLContextImpl; import jogamp.opengl.util.av.AudioSink; -import jogamp.opengl.util.av.JavaSoundAudioSink; -import jogamp.opengl.util.av.NullAudioSink; -import jogamp.opengl.openal.av.ALAudioSink; import jogamp.opengl.util.av.EGLMediaPlayerImpl; /*** @@ -130,11 +129,20 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { System.err.println("LIB_AV Codec : "+avCodecVersion); initIDs0(); available = true; - audioSink = new ALAudioSink(); - if(!audioSink.isAudioSinkAvailable()) { - audioSink = new JavaSoundAudioSink(); + final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader(); + + if(ReflectionUtil.isClassAvailable("com.jogamp.openal.ALFactory", cl)){ + // Only instance ALAudioSink if JOAL is found on the classpath. + audioSink = (AudioSink) ReflectionUtil.createInstance("jogamp.opengl.openal.av.ALAudioSink", cl); + if(!audioSink.isAudioSinkAvailable()){ + // Failed to initialize OpenAL. + audioSink=null; + } + } + if(audioSink==null) { + audioSink = (AudioSink) ReflectionUtil.createInstance("jogamp.opengl.util.av.JavaSoundAudioSink", cl); if(!audioSink.isAudioSinkAvailable()) { - audioSink = new NullAudioSink(); + audioSink = (AudioSink) ReflectionUtil.createInstance("jogamp.opengl.util.av.NullAudioSink", cl); } } maxAvailableAudio = audioSink.getDataAvailable(); -- cgit v1.2.3