aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java40
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java10
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java6
-rw-r--r--src/jogl/native/libav/ffmpeg_impl_template.c6
4 files changed, 55 insertions, 7 deletions
diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
index da6c8fde7..2c3adf957 100644
--- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java
@@ -133,6 +133,19 @@ public class ALAudioSink implements AudioSink {
staticAvailable = null != alc && null != al && null != alExt;
}
+ private void clearPreALError(final String prefix) {
+ checkALError(prefix);
+ }
+ private boolean checkALError(final String prefix) {
+ final int alcErr = alc.alcGetError(device);
+ final int alErr = al.alGetError();
+ final boolean ok = ALC.ALC_NO_ERROR == alcErr && AL.AL_NO_ERROR == alErr;
+ if( DEBUG ) {
+ System.err.println("ALAudioSink."+prefix+": ok "+ok+", err [alc "+toHexString(alcErr)+", al "+toHexString(alErr)+"]");
+ }
+ return ok;
+ }
+
public ALAudioSink() {
initialized = false;
chosenFormat = null;
@@ -147,6 +160,9 @@ public class ALAudioSink implements AudioSink {
if (device == null) {
throw new RuntimeException(getThreadName()+": ALAudioSink: Error opening default OpenAL device");
}
+ int checkErrIter = 1;
+
+ clearPreALError("init."+checkErrIter++);
// Get the device specifier.
deviceSpecifier = alc.alcGetString(device, ALC.ALC_DEVICE_SPECIFIER);
@@ -155,6 +171,8 @@ public class ALAudioSink implements AudioSink {
}
// Create audio context.
+ // final int[] attrs = new int[] { ALC.ALC_FREQUENCY, DefaultFormat.sampleRate, 0 };
+ // context = alc.alcCreateContext(device, attrs, 0);
context = alc.alcCreateContext(device, null);
if (context == null) {
throw new RuntimeException(getThreadName()+": ALAudioSink: Error creating OpenAL context for "+deviceSpecifier);
@@ -170,14 +188,18 @@ public class ALAudioSink implements AudioSink {
hasSOFTBufferSamples = al.alIsExtensionPresent(AL_SOFT_buffer_samples);
hasALC_thread_local_context = alc.alcIsExtensionPresent(null, ALC_EXT_thread_local_context) ||
alc.alcIsExtensionPresent(device, ALC_EXT_thread_local_context) ;
- preferredAudioFormat = queryPreferredAudioFormat();
+ clearPreALError("init."+checkErrIter++);
+ preferredAudioFormat = new AudioFormat(querySampleRate(), DefaultFormat.sampleSize, DefaultFormat.channelCount, DefaultFormat.signed, DefaultFormat.fixedP, DefaultFormat.planar, DefaultFormat.littleEndian);
if( DEBUG ) {
System.out.println("ALAudioSink: OpenAL Extensions:"+al.alGetString(AL.AL_EXTENSIONS));
+ clearPreALError("init."+checkErrIter++);
System.out.println("ALAudioSink: Null device OpenAL Extensions:"+alc.alcGetString(null, ALC.ALC_EXTENSIONS));
+ clearPreALError("init."+checkErrIter++);
System.out.println("ALAudioSink: Device "+deviceSpecifier+" OpenAL Extensions:"+alc.alcGetString(device, ALC.ALC_EXTENSIONS));
System.out.println("ALAudioSink: hasSOFTBufferSamples "+hasSOFTBufferSamples);
System.out.println("ALAudioSink: hasALC_thread_local_context "+hasALC_thread_local_context);
System.out.println("ALAudioSink: preferredAudioFormat "+preferredAudioFormat);
+ clearPreALError("init."+checkErrIter++);
}
// Create source
@@ -202,20 +224,28 @@ public class ALAudioSink implements AudioSink {
} catch ( Exception e ) {
if( DEBUG ) {
System.err.println(e.getMessage());
+ e.printStackTrace();
}
destroy();
}
}
}
- private final AudioFormat queryPreferredAudioFormat() {
- int sampleRate = DefaultFormat.sampleRate;
+ private final int querySampleRate() {
+ final int sampleRate;
final int[] value = new int[1];
alc.alcGetIntegerv(device, ALC.ALC_FREQUENCY, 1, value, 0);
- if ( alc.alcGetError(device) == ALC.ALC_NO_ERROR ) {
+ final int alcErr = alc.alcGetError(device);
+ final int alErr = al.alGetError();
+ if ( ALC.ALC_NO_ERROR == alcErr && AL.AL_NO_ERROR == alErr && 0 != value[0] ) {
sampleRate = value[0];
+ } else {
+ sampleRate = DefaultFormat.sampleRate;
+ }
+ if( DEBUG ) {
+ System.err.println("ALAudioSink.querySampleRate: err [alc "+toHexString(alcErr)+", al "+toHexString(alErr)+"], freq: "+value[0]+" -> "+sampleRate);
}
- return new AudioFormat(sampleRate, DefaultFormat.sampleSize, DefaultFormat.channelCount, DefaultFormat.signed, DefaultFormat.fixedP, DefaultFormat.planar, DefaultFormat.littleEndian);
+ return sampleRate;
}
private final void lockContext() {
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
index a68adb3a4..4ab90322d 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java
@@ -88,6 +88,16 @@ public class NullAudioSink implements AudioSink {
@Override
public final boolean isSupported(AudioFormat format) {
+ /**
+ * If we like to emulate constraints ..
+ *
+ if( format.planar || !format.littleEndian ) {
+ return false;
+ }
+ if( format.sampleRate != DefaultFormat.sampleRate ) {
+ return false;
+ }
+ */
return true;
}
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 4ce48bfaf..9cfd3d80e 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -138,7 +138,11 @@ import jogamp.opengl.util.av.VideoPixelFormat;
* <li>http://ffmpeg.zeranoe.com/builds/ (ffmpeg) <i>recommended, works w/ dshow</i></li>
* <li>http://win32.libav.org/releases/ (libav)</li>
* </ul></li>
- * <li>MacOSX: http://ffmpegmac.net/</li>
+ * <li>MacOSX using Homebrew
+ * <ul>
+ * <li>https://github.com/Homebrew/homebrew/wiki/Installation</li>
+ * <li>https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX</li>
+ * </ul></li>
* <li>OpenIndiana/Solaris:<pre>
* pkg set-publisher -p http://pkg.openindiana.org/sfe-encumbered.
* pkt install pkg:/video/ffmpeg
diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c
index a7e9f4857..3077070db 100644
--- a/src/jogl/native/libav/ffmpeg_impl_template.c
+++ b/src/jogl/native/libav/ffmpeg_impl_template.c
@@ -572,7 +572,7 @@ JNIEXPORT jlong JNICALL FF_FUNC(createInstance0)
pAV->aid=AV_STREAM_ID_AUTO;
if(pAV->verbose) {
- fprintf(stderr, "Info: Use avresample %d, swresample %d, device %d, refCount %d\n",
+ fprintf(stderr, "Info: Has avresample %d, swresample %d, device %d, refCount %d\n",
AV_HAS_API_AVRESAMPLE(pAV), AV_HAS_API_SWRESAMPLE(pAV), HAS_FUNC(sp_avdevice_register_all), pAV->useRefCountedFrames);
}
return (jlong) (intptr_t) pAV;
@@ -991,6 +991,10 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0)
}
}
}
+ if(pAV->verbose) {
+ fprintf(stderr, "Info: Need resample %d, Use avresample %d, swresample %d\n",
+ pAV->aSinkSupport, NULL!=pAV->avResampleCtx, NULL!=pAV->swResampleCtx);
+ }
// Allocate audio frames
// FIXME: Libav Binary compatibility! JAU01