changeset 7:37f25cb34196

transferred native interface for send.c to this project
author Robert McIntyre <rlm@mit.edu>
date Wed, 26 Oct 2011 10:42:15 -0700
parents 99df34265b40
children c54fe2f77030
files .hgignore Alc/backends/send.c CMakeLists.txt OpenAL32/Include/com_aurellem_capture_AudioSend.h java/src/com/aurellem/send/AudioSend.java
diffstat 5 files changed, 98 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/.hgignore	Tue Oct 25 13:25:47 2011 -0700
     1.2 +++ b/.hgignore	Wed Oct 26 10:42:15 2011 -0700
     1.3 @@ -1,3 +1,9 @@
     1.4  syntax: glob
     1.5  build*
     1.6  html*
     1.7 +java/.classpath
     1.8 +java/.project
     1.9 +java/bin*
    1.10 +java/dist*
    1.11 +java/build/*
    1.12 +java/headers/*
    1.13 \ No newline at end of file
     2.1 --- a/Alc/backends/send.c	Tue Oct 25 13:25:47 2011 -0700
     2.2 +++ b/Alc/backends/send.c	Wed Oct 26 10:42:15 2011 -0700
     2.3 @@ -274,25 +274,25 @@
     2.4  
     2.5  ////////////////////   JNI Methods
     2.6  
     2.7 -#include "com_aurellem_capture_AudioSend.h"
     2.8 +#include "com_aurellem_send_AudioSend.h"
     2.9  
    2.10  /*
    2.11 - * Class:     com_aurellem_capture_AudioSend
    2.12 + * Class:     com_aurellem_send_AudioSend
    2.13   * Method:    nstep
    2.14   * Signature: (JI)V
    2.15   */
    2.16 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nstep
    2.17 +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nstep
    2.18  (JNIEnv *env, jclass clazz, jlong device, jint samples){
    2.19    UNUSED(env);UNUSED(clazz);UNUSED(device);
    2.20    renderData((ALCdevice*)((intptr_t)device), samples);
    2.21  }
    2.22  
    2.23  /*
    2.24 - * Class:     com_aurellem_capture_AudioSend
    2.25 + * Class:     com_aurellem_send_AudioSend
    2.26   * Method:    ngetSamples
    2.27   * Signature: (JLjava/nio/ByteBuffer;III)V
    2.28   */
    2.29 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ngetSamples
    2.30 +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ngetSamples
    2.31  (JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, 
    2.32   jint samples, jint n){
    2.33    UNUSED(clazz);  
    2.34 @@ -309,11 +309,11 @@
    2.35  }
    2.36  
    2.37  /*
    2.38 - * Class:     com_aurellem_capture_AudioSend
    2.39 + * Class:     com_aurellem_send_AudioSend
    2.40   * Method:    naddListener
    2.41   * Signature: (J)V
    2.42   */
    2.43 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_naddListener
    2.44 +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_naddListener
    2.45  (JNIEnv *env, jclass clazz, jlong device){
    2.46    UNUSED(env); UNUSED(clazz);
    2.47    printf("creating new context via naddListener\n");
    2.48 @@ -323,11 +323,11 @@
    2.49  }
    2.50  
    2.51  /*
    2.52 - * Class:     com_aurellem_capture_AudioSend
    2.53 + * Class:     com_aurellem_send_AudioSend
    2.54   * Method:    nsetNthListener3f
    2.55   * Signature: (IFFFJI)V
    2.56   */
    2.57 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListener3f
    2.58 +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListener3f
    2.59    (JNIEnv *env, jclass clazz, jint param, 
    2.60     jfloat v1, jfloat v2, jfloat v3, jlong device, jint contextNum){
    2.61    UNUSED(env);UNUSED(clazz);
    2.62 @@ -343,11 +343,11 @@
    2.63  }
    2.64  
    2.65  /*
    2.66 - * Class:     com_aurellem_capture_AudioSend
    2.67 + * Class:     com_aurellem_send_AudioSend
    2.68   * Method:    nsetNthListenerf
    2.69   * Signature: (IFJI)V
    2.70   */
    2.71 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListenerf
    2.72 +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListenerf
    2.73  (JNIEnv *env, jclass clazz, jint param, jfloat v1, jlong device, 
    2.74   jint contextNum){
    2.75  
    2.76 @@ -364,11 +364,11 @@
    2.77  }
    2.78  
    2.79  /*
    2.80 - * Class:     com_aurellem_capture_AudioSend
    2.81 + * Class:     com_aurellem_send_AudioSend
    2.82   * Method:    ninitDevice
    2.83   * Signature: (J)V
    2.84   */                     
    2.85 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ninitDevice
    2.86 +JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ninitDevice
    2.87  (JNIEnv *env, jclass clazz, jlong device){
    2.88    UNUSED(env);UNUSED(clazz);
    2.89    
     3.1 --- a/CMakeLists.txt	Tue Oct 25 13:25:47 2011 -0700
     3.2 +++ b/CMakeLists.txt	Wed Oct 26 10:42:15 2011 -0700
     3.3 @@ -65,7 +65,7 @@
     3.4  
     3.5  
     3.6  # Add definitions, compiler switches, etc.
     3.7 -INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
     3.8 +INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}" java/headers)
     3.9  
    3.10  IF(NOT CMAKE_BUILD_TYPE)
    3.11      SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
     4.1 --- a/OpenAL32/Include/com_aurellem_capture_AudioSend.h	Tue Oct 25 13:25:47 2011 -0700
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,63 +0,0 @@
     4.4 -/* DO NOT EDIT THIS FILE - it is machine generated */
     4.5 -#include <jni.h>
     4.6 -/* Header for class com_aurellem_capture_AudioSend */
     4.7 -
     4.8 -#ifndef _Included_com_aurellem_capture_AudioSend
     4.9 -#define _Included_com_aurellem_capture_AudioSend
    4.10 -#ifdef __cplusplus
    4.11 -extern "C" {
    4.12 -#endif
    4.13 -#undef com_aurellem_capture_AudioSend_BYTES_PER_SAMPLE
    4.14 -#define com_aurellem_capture_AudioSend_BYTES_PER_SAMPLE 4L
    4.15 -/*
    4.16 - * Class:     com_aurellem_capture_AudioSend
    4.17 - * Method:    ninitDevice
    4.18 - * Signature: (J)V
    4.19 - */
    4.20 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ninitDevice
    4.21 -  (JNIEnv *, jclass, jlong);
    4.22 -
    4.23 -/*
    4.24 - * Class:     com_aurellem_capture_AudioSend
    4.25 - * Method:    nstep
    4.26 - * Signature: (JI)V
    4.27 - */
    4.28 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nstep
    4.29 -  (JNIEnv *, jclass, jlong, jint);
    4.30 -
    4.31 -/*
    4.32 - * Class:     com_aurellem_capture_AudioSend
    4.33 - * Method:    ngetSamples
    4.34 - * Signature: (JLjava/nio/ByteBuffer;III)V
    4.35 - */
    4.36 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_ngetSamples
    4.37 -  (JNIEnv *, jclass, jlong, jobject, jint, jint, jint);
    4.38 -
    4.39 -/*
    4.40 - * Class:     com_aurellem_capture_AudioSend
    4.41 - * Method:    naddListener
    4.42 - * Signature: (J)V
    4.43 - */
    4.44 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_naddListener
    4.45 -  (JNIEnv *, jclass, jlong);
    4.46 -
    4.47 -/*
    4.48 - * Class:     com_aurellem_capture_AudioSend
    4.49 - * Method:    nsetNthListener3f
    4.50 - * Signature: (IFFFJI)V
    4.51 - */
    4.52 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListener3f
    4.53 -  (JNIEnv *, jclass, jint, jfloat, jfloat, jfloat, jlong, jint);
    4.54 -
    4.55 -/*
    4.56 - * Class:     com_aurellem_capture_AudioSend
    4.57 - * Method:    nsetNthListenerf
    4.58 - * Signature: (IFJI)V
    4.59 - */
    4.60 -JNIEXPORT void JNICALL Java_com_aurellem_capture_AudioSend_nsetNthListenerf
    4.61 -  (JNIEnv *, jclass, jint, jfloat, jlong, jint);
    4.62 -
    4.63 -#ifdef __cplusplus
    4.64 -}
    4.65 -#endif
    4.66 -#endif
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/java/src/com/aurellem/send/AudioSend.java	Wed Oct 26 10:42:15 2011 -0700
     5.3 @@ -0,0 +1,78 @@
     5.4 +package com.aurellem.send;
     5.5 +
     5.6 +import java.nio.ByteBuffer;
     5.7 +
     5.8 +public class AudioSend {
     5.9 +
    5.10 +	private final long deviceID;
    5.11 +	
    5.12 +	public AudioSend(long deviceID){
    5.13 +		this.deviceID = deviceID;
    5.14 +	}
    5.15 +	
    5.16 +	/** This establishes the LWJGL context as the context which will be copies to all 
    5.17 +	 *  other contexts.  It must be called before any calls to <code>addListener();</code>
    5.18 +	 */
    5.19 +	public void initDevice(){
    5.20 +		ninitDevice(this.deviceID);}
    5.21 +	public static native void ninitDevice(long device);
    5.22 +	
    5.23 +	/**
    5.24 +	 * The send device does not automatically process sound.  This step function will cause 
    5.25 +	 * the desired number of samples to be processed for each listener.  The results will then 
    5.26 +	 * be available via calls to <code>getSamples()</code> for each listener.
    5.27 +	 * @param samples
    5.28 +	 */
    5.29 +	public void step(int samples){
    5.30 +		nstep(this.deviceID, samples);}
    5.31 +	public static native void nstep(long device, int samples);
    5.32 +
    5.33 +	/**
    5.34 +	 * Retrieve the final rendered sound for a particular listener.  <code>contextNum == 0</code>
    5.35 +	 * is the main LWJGL context.
    5.36 +	 * @param buffer
    5.37 +	 * @param samples
    5.38 +	 * @param contextNum
    5.39 +	 */
    5.40 +	public void getSamples(ByteBuffer buffer, int samples, int contextNum){
    5.41 +		ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);}
    5.42 +	public static native void ngetSamples(
    5.43 +			long device, ByteBuffer buffer, int position, int samples, int contextNum);
    5.44 +	
    5.45 +	/**
    5.46 +	 * Create an additional listener on the recorder device.  The device itself will manage 
    5.47 +	 * this listener and synchronize it with the main LWJGL context. Processed sound samples
    5.48 +	 * for this listener will be available via a call to <code>getSamples()</code> with 
    5.49 +	 * <code>contextNum</code> equal to the number of times this method has been called. 
    5.50 +	 */
    5.51 +	public void addListener(){naddListener(this.deviceID);}
    5.52 +	public static native void naddListener(long device);
    5.53 +	
    5.54 +	/**
    5.55 +	 * This will internally call <code>alListener3f<code> in the appropriate slave context and update
    5.56 +	 * that context's listener's parameters. Calling this for a number greater than the current 
    5.57 +	 * number of slave contexts will have no effect.
    5.58 +	 * @param pname
    5.59 +	 * @param v1
    5.60 +	 * @param v2
    5.61 +	 * @param v3
    5.62 +	 * @param contextNum
    5.63 +	 */
    5.64 +	public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){
    5.65 +		nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);}
    5.66 +	public static native void 
    5.67 +	nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum);
    5.68 +	
    5.69 +	/**
    5.70 +	 * This will internally call <code>alListenerf<code> in the appropriate slave context and update
    5.71 +	 * that context's listener's parameters. Calling this for a number greater than the current 
    5.72 +	 * number of slave contexts will have no effect.
    5.73 +	 * @param pname
    5.74 +	 * @param v1
    5.75 +	 * @param contextNum
    5.76 +	 */
    5.77 +	public void setNthListenerf(int pname, float v1, int contextNum){
    5.78 +		nsetNthListenerf(pname, v1, this.deviceID, contextNum);}
    5.79 +	public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum);
    5.80 +	
    5.81 +}