aboutsummaryrefslogtreecommitdiffstats
path: root/src/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-12-13 07:30:20 +0100
committerSven Gothel <[email protected]>2010-12-13 07:30:20 +0100
commitb0c39f3f4259cf6eca8e1f7af0f0924cf7472abe (patch)
tree613781a5703e2052c21b1c35242c3d948bebcf72 /src/native
parenta68be2859454b75539cc5e44eb23129745932db3 (diff)
Bring back JOAL (code fixes and project structure)
- Use GlueGen DynamicLibraryBundle - Fix alGetString - Proper test/junit structure - NB project fix - add artifacts.properties and jar's manifest - proper ZIP file structure TODO: - check on windows and osx - actually hear a sound - add jnlp file template - joal-demos
Diffstat (limited to 'src/native')
-rw-r--r--src/native/almisc.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/native/almisc.c b/src/native/almisc.c
new file mode 100644
index 0000000..6658f64
--- /dev/null
+++ b/src/native/almisc.c
@@ -0,0 +1,71 @@
+
+#include <jni.h>
+#include <stdlib.h>
+
+#include <assert.h>
+
+ #include "al.h"
+ #include "alc.h"
+ #ifndef _MSC_VER /* Non-Windows platforms */
+ #define __cdecl /* Trim non-standard keyword */
+ #endif
+ #include "efx.h"
+ #ifdef _MSC_VER /* Windows, Microsoft compilers */
+ /* This typedef is apparently needed for compilers before VC8 */
+ #if _MSC_VER < 1400
+ typedef int intptr_t;
+ #endif
+ #else
+ /* This header seems to be available on all other platforms */
+ #include <inttypes.h>
+ #endif
+ #include <string.h>
+
+
+/* Java->C glue code:
+ * Java package: com.jogamp.openal.impl.ALImpl
+ * Java method: long dispatch_alGetProcAddressStatic(java.lang.String fname)
+ * C function: ALproc alGetProcAddress(const ALchar * fname);
+ */
+JNIEXPORT jlong JNICALL
+Java_com_jogamp_openal_impl_ALImpl_dispatch_1alGetProcAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) {
+ LPALGETPROCADDRESS ptr_alGetProcAddress;
+ const char* _strchars_fname = NULL;
+ ALproc _res;
+ if ( NULL != fname ) {
+ _strchars_fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL);
+ if ( NULL == _strchars_fname ) {
+ (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"),
+ "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"dispatch_alGetProcAddress\"");
+ return 0;
+ }
+ }
+ ptr_alGetProcAddress = (LPALGETPROCADDRESS) (intptr_t) procAddress;
+ assert(ptr_alGetProcAddress != NULL);
+ _res = (* ptr_alGetProcAddress) ((ALchar *) _strchars_fname);
+ if ( NULL != fname ) {
+ (*env)->ReleaseStringUTFChars(env, fname, _strchars_fname);
+ }
+ return (jlong) (intptr_t) _res;
+}
+
+/* Java->C glue code:
+ * Java package: com.jogamp.openal.impl.ALCAbstractImpl
+ * Java method: java.nio.ByteBuffer dispatch_alcGetStringImpl(ALCdevice device, int param)
+ * C function: const ALCchar * alcGetString(ALCdevice * device, ALCenum param);
+ */
+JNIEXPORT jobject JNICALL
+Java_com_jogamp_openal_impl_ALCImpl_dispatch_1alcGetStringImpl1(JNIEnv *env, jobject _unused, jobject device, jint param, jlong procAddress) {
+ LPALCGETSTRING ptr_alcGetString;
+ ALCdevice * _device_ptr = NULL;
+ const ALCchar * _res;
+ if ( NULL != device ) {
+ _device_ptr = (ALCdevice *) (((char*) (*env)->GetDirectBufferAddress(env, device)) + 0);
+ }
+ ptr_alcGetString = (LPALCGETSTRING) (intptr_t) procAddress;
+ assert(ptr_alcGetString != NULL);
+ _res = (* ptr_alcGetString) ((ALCdevice *) _device_ptr, (ALCenum) param);
+ if (NULL == _res) return NULL;
+ return (*env)->NewDirectByteBuffer(env, _res, strlen_alc(_device_ptr, param, _res));
+}
+