# HG changeset patch # User Robert McIntyre # Date 1319650935 25200 # Node ID 37f25cb34196a30ece8e804e8f5fad6c71bc53d3 # Parent 99df34265b40a45e83c2bcaf524112caecefebff transferred native interface for send.c to this project diff -r 99df34265b40 -r 37f25cb34196 .hgignore --- a/.hgignore Tue Oct 25 13:25:47 2011 -0700 +++ b/.hgignore Wed Oct 26 10:42:15 2011 -0700 @@ -1,3 +1,9 @@ syntax: glob build* html* +java/.classpath +java/.project +java/bin* +java/dist* +java/build/* +java/headers/* \ No newline at end of file diff -r 99df34265b40 -r 37f25cb34196 Alc/backends/send.c --- a/Alc/backends/send.c Tue Oct 25 13:25:47 2011 -0700 +++ b/Alc/backends/send.c Wed Oct 26 10:42:15 2011 -0700 @@ -274,25 +274,25 @@ //////////////////// JNI Methods -#include "com_aurellem_capture_AudioSend.h" +#include "com_aurellem_send_AudioSend.h" /* - * Class: com_aurellem_capture_AudioSend + * Class: com_aurellem_send_AudioSend * Method: nstep * Signature: (JI)V */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nstep +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nstep (JNIEnv *env, jclass clazz, jlong device, jint samples){ UNUSED(env);UNUSED(clazz);UNUSED(device); renderData((ALCdevice*)((intptr_t)device), samples); } /* - * Class: com_aurellem_capture_AudioSend + * Class: com_aurellem_send_AudioSend * Method: ngetSamples * Signature: (JLjava/nio/ByteBuffer;III)V */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ngetSamples +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ngetSamples (JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, jint samples, jint n){ UNUSED(clazz); @@ -309,11 +309,11 @@ } /* - * Class: com_aurellem_capture_AudioSend + * Class: com_aurellem_send_AudioSend * Method: naddListener * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_naddListener +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_naddListener (JNIEnv *env, jclass clazz, jlong device){ UNUSED(env); UNUSED(clazz); printf("creating new context via naddListener\n"); @@ -323,11 +323,11 @@ } /* - * Class: com_aurellem_capture_AudioSend + * Class: com_aurellem_send_AudioSend * Method: nsetNthListener3f * Signature: (IFFFJI)V */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListener3f +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListener3f (JNIEnv *env, jclass clazz, jint param, jfloat v1, jfloat v2, jfloat v3, jlong device, jint contextNum){ UNUSED(env);UNUSED(clazz); @@ -343,11 +343,11 @@ } /* - * Class: com_aurellem_capture_AudioSend + * Class: com_aurellem_send_AudioSend * Method: nsetNthListenerf * Signature: (IFJI)V */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListenerf +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListenerf (JNIEnv *env, jclass clazz, jint param, jfloat v1, jlong device, jint contextNum){ @@ -364,11 +364,11 @@ } /* - * Class: com_aurellem_capture_AudioSend + * Class: com_aurellem_send_AudioSend * Method: ninitDevice * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ninitDevice +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ninitDevice (JNIEnv *env, jclass clazz, jlong device){ UNUSED(env);UNUSED(clazz); diff -r 99df34265b40 -r 37f25cb34196 CMakeLists.txt --- a/CMakeLists.txt Tue Oct 25 13:25:47 2011 -0700 +++ b/CMakeLists.txt Wed Oct 26 10:42:15 2011 -0700 @@ -65,7 +65,7 @@ # Add definitions, compiler switches, etc. -INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}") +INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}" java/headers) IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING diff -r 99df34265b40 -r 37f25cb34196 OpenAL32/Include/com_aurellem_capture_AudioSend.h --- a/OpenAL32/Include/com_aurellem_capture_AudioSend.h Tue Oct 25 13:25:47 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class com_aurellem_capture_AudioSend */ - -#ifndef _Included_com_aurellem_capture_AudioSend -#define _Included_com_aurellem_capture_AudioSend -#ifdef __cplusplus -extern "C" { -#endif -#undef com_aurellem_capture_AudioSend_BYTES_PER_SAMPLE -#define com_aurellem_capture_AudioSend_BYTES_PER_SAMPLE 4L -/* - * Class: com_aurellem_capture_AudioSend - * Method: ninitDevice - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ninitDevice - (JNIEnv *, jclass, jlong); - -/* - * Class: com_aurellem_capture_AudioSend - * Method: nstep - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nstep - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: com_aurellem_capture_AudioSend - * Method: ngetSamples - * Signature: (JLjava/nio/ByteBuffer;III)V - */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ngetSamples - (JNIEnv *, jclass, jlong, jobject, jint, jint, jint); - -/* - * Class: com_aurellem_capture_AudioSend - * Method: naddListener - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_naddListener - (JNIEnv *, jclass, jlong); - -/* - * Class: com_aurellem_capture_AudioSend - * Method: nsetNthListener3f - * Signature: (IFFFJI)V - */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListener3f - (JNIEnv *, jclass, jint, jfloat, jfloat, jfloat, jlong, jint); - -/* - * Class: com_aurellem_capture_AudioSend - * Method: nsetNthListenerf - * Signature: (IFJI)V - */ -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListenerf - (JNIEnv *, jclass, jint, jfloat, jlong, jint); - -#ifdef __cplusplus -} -#endif -#endif diff -r 99df34265b40 -r 37f25cb34196 java/src/com/aurellem/send/AudioSend.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/com/aurellem/send/AudioSend.java Wed Oct 26 10:42:15 2011 -0700 @@ -0,0 +1,78 @@ +package com.aurellem.send; + +import java.nio.ByteBuffer; + +public class AudioSend { + + private final long deviceID; + + public AudioSend(long deviceID){ + this.deviceID = deviceID; + } + + /** This establishes the LWJGL context as the context which will be copies to all + * other contexts. It must be called before any calls to addListener(); + */ + public void initDevice(){ + ninitDevice(this.deviceID);} + public static native void ninitDevice(long device); + + /** + * The send device does not automatically process sound. This step function will cause + * the desired number of samples to be processed for each listener. The results will then + * be available via calls to getSamples() for each listener. + * @param samples + */ + public void step(int samples){ + nstep(this.deviceID, samples);} + public static native void nstep(long device, int samples); + + /** + * Retrieve the final rendered sound for a particular listener. contextNum == 0 + * is the main LWJGL context. + * @param buffer + * @param samples + * @param contextNum + */ + public void getSamples(ByteBuffer buffer, int samples, int contextNum){ + ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);} + public static native void ngetSamples( + long device, ByteBuffer buffer, int position, int samples, int contextNum); + + /** + * Create an additional listener on the recorder device. The device itself will manage + * this listener and synchronize it with the main LWJGL context. Processed sound samples + * for this listener will be available via a call to getSamples() with + * contextNum equal to the number of times this method has been called. + */ + public void addListener(){naddListener(this.deviceID);} + public static native void naddListener(long device); + + /** + * This will internally call alListener3f in the appropriate slave context and update + * that context's listener's parameters. Calling this for a number greater than the current + * number of slave contexts will have no effect. + * @param pname + * @param v1 + * @param v2 + * @param v3 + * @param contextNum + */ + public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){ + nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);} + public static native void + nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum); + + /** + * This will internally call alListenerf in the appropriate slave context and update + * that context's listener's parameters. Calling this for a number greater than the current + * number of slave contexts will have no effect. + * @param pname + * @param v1 + * @param contextNum + */ + public void setNthListenerf(int pname, float v1, int contextNum){ + nsetNthListenerf(pname, v1, this.deviceID, contextNum);} + public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum); + +}