changeset 17:fdf84bc57e67

forgetting send.c
author Robert McIntyre <rlm@mit.edu>
date Thu, 03 Nov 2011 12:12:05 -0700
parents 3de8325e79bf
children 1e201037f666
files .hgignore Alc/backends/send.c
diffstat 2 files changed, 2 insertions(+), 519 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/.hgignore	Thu Nov 03 12:09:54 2011 -0700
     1.2 +++ b/.hgignore	Thu Nov 03 12:12:05 2011 -0700
     1.3 @@ -1,4 +1,5 @@
     1.4  syntax: glob
     1.5 +send.c
     1.6  build*
     1.7  html*
     1.8  java/.classpath
     1.9 @@ -7,4 +8,4 @@
    1.10  java/dist*
    1.11  java/build/*
    1.12  java/headers/*
    1.13 -Alc/backends/send.c
    1.14 +
     2.1 --- a/Alc/backends/send.c	Thu Nov 03 12:09:54 2011 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,518 +0,0 @@
     2.4 -
     2.5 -#include "config.h"
     2.6 -#include <stdlib.h>
     2.7 -#include "alMain.h"
     2.8 -#include "AL/al.h"
     2.9 -#include "AL/alc.h"
    2.10 -#include "alSource.h"
    2.11 -#include <jni.h>
    2.12 -
    2.13 -//////////////////// Summary
    2.14 -
    2.15 -struct send_data;
    2.16 -struct context_data;
    2.17 -
    2.18 -static void addContext(ALCdevice *, ALCcontext *);
    2.19 -static void syncContexts(ALCcontext *master, ALCcontext *slave);
    2.20 -static void syncSources(ALsource *master, ALsource *slave, 
    2.21 -			ALCcontext *masterCtx, ALCcontext *slaveCtx);
    2.22 -
    2.23 -static void syncSourcei(ALuint master, ALuint slave,
    2.24 -			ALCcontext *masterCtx, ALCcontext *ctx2, ALenum param);
    2.25 -static void syncSourcef(ALuint master, ALuint slave,
    2.26 -			ALCcontext *masterCtx, ALCcontext *ctx2, ALenum param);
    2.27 -static void syncSource3f(ALuint master, ALuint slave,
    2.28 -			ALCcontext *masterCtx, ALCcontext *ctx2, ALenum param);
    2.29 -
    2.30 -static void swapInContext(ALCdevice *, struct context_data *);
    2.31 -static void saveContext(ALCdevice *, struct context_data *);
    2.32 -static void limitContext(ALCdevice *, ALCcontext *);
    2.33 -static void unLimitContext(ALCdevice *);
    2.34 -
    2.35 -static void init(ALCdevice *);
    2.36 -static void renderData(ALCdevice *, int samples);
    2.37 -
    2.38 -#define UNUSED(x)  (void)(x)
    2.39 -
    2.40 -////////////////////  State
    2.41 -
    2.42 -typedef struct context_data {
    2.43 -  ALfloat ClickRemoval[MAXCHANNELS];
    2.44 -  ALfloat PendingClicks[MAXCHANNELS];
    2.45 -  ALvoid *renderBuffer;
    2.46 -  ALCcontext *ctx;
    2.47 -} context_data;
    2.48 -
    2.49 -typedef struct send_data {
    2.50 -  ALuint size;
    2.51 -  context_data **contexts;
    2.52 -  ALuint numContexts;
    2.53 -  ALuint maxContexts;
    2.54 -} send_data;
    2.55 -
    2.56 -
    2.57 -
    2.58 -////////////////////  Context Creation / Synchronization
    2.59 -
    2.60 -#define _MAKE_SYNC(NAME, INIT_EXPR, GET_EXPR, SET_EXPR)	\
    2.61 -  void NAME (ALuint sourceID1, ALuint sourceID2,	\
    2.62 -	     ALCcontext *ctx1, ALCcontext *ctx2,	\
    2.63 -	     ALenum param){				\
    2.64 -    INIT_EXPR;						\
    2.65 -    ALCcontext *current = alcGetCurrentContext();	\
    2.66 -    alcMakeContextCurrent(ctx1);			\
    2.67 -    GET_EXPR;						\
    2.68 -    alcMakeContextCurrent(ctx2);			\
    2.69 -    SET_EXPR;						\
    2.70 -    alcMakeContextCurrent(current);			\
    2.71 -  }
    2.72 -  
    2.73 -#define MAKE_SYNC(NAME, TYPE, GET, SET)			\
    2.74 -  _MAKE_SYNC(NAME,					\
    2.75 -	     TYPE value,				\
    2.76 -             GET(sourceID1, param, &value),		\
    2.77 -             SET(sourceID2, param, value))
    2.78 -  
    2.79 -#define MAKE_SYNC3(NAME, TYPE, GET, SET)				\
    2.80 -  _MAKE_SYNC(NAME,							\
    2.81 -	     TYPE value1; TYPE value2; TYPE value3;,			\
    2.82 -	     GET(sourceID1, param, &value1, &value2, &value3),		\
    2.83 -	     SET(sourceID2, param,  value1,  value2,  value3))
    2.84 -
    2.85 -MAKE_SYNC( syncSourcei,  ALint,   alGetSourcei,  alSourcei);
    2.86 -MAKE_SYNC( syncSourcef,  ALfloat, alGetSourcef,  alSourcef);
    2.87 -MAKE_SYNC3(syncSource3i, ALint,   alGetSource3i, alSource3i);
    2.88 -MAKE_SYNC3(syncSource3f, ALfloat, alGetSource3f, alSource3f);
    2.89 -  
    2.90 -void syncSources(ALsource *masterSource, ALsource *slaveSource, 
    2.91 -		 ALCcontext *masterCtx, ALCcontext *slaveCtx){
    2.92 -  ALuint master = masterSource->source;
    2.93 -  ALuint slave = slaveSource->source;
    2.94 -  ALCcontext *current = alcGetCurrentContext();
    2.95 -
    2.96 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_PITCH);
    2.97 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_GAIN);
    2.98 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_MAX_DISTANCE);
    2.99 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_ROLLOFF_FACTOR);
   2.100 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_REFERENCE_DISTANCE);
   2.101 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_MIN_GAIN);
   2.102 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_MAX_GAIN);
   2.103 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_CONE_OUTER_GAIN);
   2.104 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_CONE_INNER_ANGLE);
   2.105 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_CONE_OUTER_ANGLE);
   2.106 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_SEC_OFFSET);
   2.107 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_SAMPLE_OFFSET);
   2.108 -  syncSourcef(master,slave,masterCtx,slaveCtx,AL_BYTE_OFFSET);
   2.109 -    
   2.110 -  syncSource3f(master,slave,masterCtx,slaveCtx,AL_POSITION);
   2.111 -  syncSource3f(master,slave,masterCtx,slaveCtx,AL_VELOCITY);
   2.112 -  syncSource3f(master,slave,masterCtx,slaveCtx,AL_DIRECTION);
   2.113 -  
   2.114 -  syncSourcei(master,slave,masterCtx,slaveCtx,AL_SOURCE_RELATIVE);
   2.115 -  syncSourcei(master,slave,masterCtx,slaveCtx,AL_LOOPING);
   2.116 -
   2.117 -  alcMakeContextCurrent(masterCtx);
   2.118 -  ALint source_type;
   2.119 -  alGetSourcei(master, AL_SOURCE_TYPE, &source_type);
   2.120 -
   2.121 -  // Only static sources are currently synchronized! 
   2.122 -  if (AL_STATIC == source_type){
   2.123 -    ALint master_buffer;
   2.124 -    ALint slave_buffer;
   2.125 -    alGetSourcei(master, AL_BUFFER, &master_buffer);
   2.126 -    alcMakeContextCurrent(slaveCtx);
   2.127 -    alGetSourcei(slave, AL_BUFFER, &slave_buffer);
   2.128 -    if (master_buffer != slave_buffer){
   2.129 -      alSourcei(slave, AL_BUFFER, master_buffer);
   2.130 -    }
   2.131 -  }
   2.132 -  
   2.133 -  // Synchronize the state of the two sources.
   2.134 -  alcMakeContextCurrent(masterCtx);
   2.135 -  ALint masterState;
   2.136 -  ALint slaveState;
   2.137 -
   2.138 -  alGetSourcei(master, AL_SOURCE_STATE, &masterState);
   2.139 -  alcMakeContextCurrent(slaveCtx);
   2.140 -  alGetSourcei(slave, AL_SOURCE_STATE, &slaveState);
   2.141 -
   2.142 -  if (masterState != slaveState){
   2.143 -    switch (masterState){
   2.144 -    case AL_INITIAL : alSourceRewind(slave); break;
   2.145 -    case AL_PLAYING : alSourcePlay(slave);   break;
   2.146 -    case AL_PAUSED  : alSourcePause(slave);  break;
   2.147 -    case AL_STOPPED : alSourceStop(slave);   break;
   2.148 -    }
   2.149 -  }
   2.150 -  // Restore whatever context was previously active.
   2.151 -  alcMakeContextCurrent(current);
   2.152 -}
   2.153 -
   2.154 -
   2.155 -void syncContexts(ALCcontext *master, ALCcontext *slave){
   2.156 -  /* If there aren't sufficient sources in slave to mirror 
   2.157 -     the sources in master, create them. */
   2.158 -  ALCcontext *current = alcGetCurrentContext();
   2.159 -
   2.160 -  UIntMap *masterSourceMap = &(master->SourceMap);
   2.161 -  UIntMap *slaveSourceMap = &(slave->SourceMap);
   2.162 -  ALuint numMasterSources = masterSourceMap->size;
   2.163 -  ALuint numSlaveSources = slaveSourceMap->size;
   2.164 -
   2.165 -  alcMakeContextCurrent(slave);
   2.166 -  if (numSlaveSources < numMasterSources){
   2.167 -    ALuint numMissingSources = numMasterSources - numSlaveSources;
   2.168 -    ALuint newSources[numMissingSources];
   2.169 -    alGenSources(numMissingSources, newSources);
   2.170 -  }
   2.171 -
   2.172 -  /* Now, slave is gauranteed to have at least as many sources
   2.173 -     as master.  Sync each source from master to the corresponding
   2.174 -     source in slave. */
   2.175 -  int i;
   2.176 -  for(i = 0; i < masterSourceMap->size; i++){
   2.177 -    syncSources((ALsource*)masterSourceMap->array[i].value,
   2.178 -		(ALsource*)slaveSourceMap->array[i].value,
   2.179 -		master, slave);
   2.180 -  }
   2.181 -  alcMakeContextCurrent(current);
   2.182 -}
   2.183 -
   2.184 -static void addContext(ALCdevice *Device, ALCcontext *context){
   2.185 -  send_data *data = (send_data*)Device->ExtraData;
   2.186 -  // expand array if necessary
   2.187 -  if (data->numContexts >= data->maxContexts){
   2.188 -    ALuint newMaxContexts = data->maxContexts*2 + 1;
   2.189 -    data->contexts = realloc(data->contexts, newMaxContexts*sizeof(context_data));
   2.190 -    data->maxContexts = newMaxContexts;
   2.191 -  }
   2.192 -  // create context_data and add it to the main array
   2.193 -  context_data *ctxData;
   2.194 -  ctxData = (context_data*)calloc(1, sizeof(*ctxData));
   2.195 -  ctxData->renderBuffer = 
   2.196 -    malloc(BytesFromDevFmt(Device->FmtType) * 
   2.197 -	   Device->NumChan * Device->UpdateSize);
   2.198 -  ctxData->ctx = context;
   2.199 -
   2.200 -  data->contexts[data->numContexts] = ctxData;
   2.201 -  data->numContexts++;
   2.202 -}
   2.203 -
   2.204 -
   2.205 -////////////////////  Context Switching 
   2.206 -
   2.207 -/* A device brings along with it two pieces of state
   2.208 - * which have to be swapped in and out with each context.
   2.209 - */
   2.210 -static void swapInContext(ALCdevice *Device, context_data *ctxData){
   2.211 -  memcpy(Device->ClickRemoval, ctxData->ClickRemoval, sizeof(ALfloat)*MAXCHANNELS);
   2.212 -  memcpy(Device->PendingClicks, ctxData->PendingClicks, sizeof(ALfloat)*MAXCHANNELS);
   2.213 -}
   2.214 -
   2.215 -static void saveContext(ALCdevice *Device, context_data *ctxData){
   2.216 -  memcpy(ctxData->ClickRemoval, Device->ClickRemoval, sizeof(ALfloat)*MAXCHANNELS);
   2.217 -  memcpy(ctxData->PendingClicks, Device->PendingClicks, sizeof(ALfloat)*MAXCHANNELS);
   2.218 -}  
   2.219 -
   2.220 -static ALCcontext **currentContext;
   2.221 -static ALuint currentNumContext;
   2.222 -
   2.223 -/* By default, all contexts are rendered at once for each call to aluMixData.
   2.224 - * This function uses the internals of the ALCdecice struct to temporarly 
   2.225 - * cause aluMixData to only render the chosen context.
   2.226 - */
   2.227 -static void limitContext(ALCdevice *Device, ALCcontext *ctx){
   2.228 -  currentContext  = Device->Contexts;
   2.229 -  currentNumContext  = Device->NumContexts;
   2.230 -  Device->Contexts = &ctx;
   2.231 -  Device->NumContexts = 1;
   2.232 -}
   2.233 -
   2.234 -static void unLimitContext(ALCdevice *Device){
   2.235 -  Device->Contexts = currentContext;
   2.236 -  Device->NumContexts = currentNumContext;
   2.237 -}
   2.238 -
   2.239 -
   2.240 -////////////////////   Main Device Loop
   2.241 -
   2.242 -/* Establish the LWJGL context as the main context, which will
   2.243 - * be synchronized to all the slave contexts
   2.244 - */
   2.245 -static void init(ALCdevice *Device){
   2.246 -  ALCcontext *masterContext = alcGetCurrentContext();
   2.247 -  addContext(Device, masterContext);
   2.248 -}
   2.249 -
   2.250 -
   2.251 -static void renderData(ALCdevice *Device, int samples){
   2.252 -  if(!Device->Connected){return;}
   2.253 -  send_data *data = (send_data*)Device->ExtraData;
   2.254 -  ALCcontext *current = alcGetCurrentContext();
   2.255 -
   2.256 -  ALuint i;
   2.257 -  for (i = 1; i < data->numContexts; i++){
   2.258 -    syncContexts(data->contexts[0]->ctx , data->contexts[i]->ctx);
   2.259 -  }
   2.260 -  
   2.261 -  if ((uint) samples > Device->UpdateSize){
   2.262 -    printf("exceeding internal buffer size; dropping samples\n");
   2.263 -    printf("requested %d; available %d\n", samples, Device->UpdateSize);
   2.264 -    samples = (int) Device->UpdateSize;
   2.265 -  }
   2.266 -
   2.267 -  for (i = 0; i < data->numContexts; i++){
   2.268 -    context_data *ctxData = data->contexts[i];
   2.269 -    ALCcontext *ctx = ctxData->ctx;
   2.270 -    alcMakeContextCurrent(ctx);
   2.271 -    limitContext(Device, ctx);
   2.272 -    swapInContext(Device, ctxData);
   2.273 -    aluMixData(Device, ctxData->renderBuffer, samples);
   2.274 -    saveContext(Device, ctxData);
   2.275 -    unLimitContext(Device);
   2.276 -  }
   2.277 -  alcMakeContextCurrent(current);
   2.278 -}
   2.279 -
   2.280 -
   2.281 -////////////////////   JNI Methods
   2.282 -
   2.283 -#include "com_aurellem_send_AudioSend.h"
   2.284 -
   2.285 -/*
   2.286 - * Class:     com_aurellem_send_AudioSend
   2.287 - * Method:    nstep
   2.288 - * Signature: (JI)V
   2.289 - */
   2.290 -JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nstep
   2.291 -(JNIEnv *env, jclass clazz, jlong device, jint samples){
   2.292 -  UNUSED(env);UNUSED(clazz);UNUSED(device);
   2.293 -  renderData((ALCdevice*)((intptr_t)device), samples);
   2.294 -}
   2.295 -
   2.296 -/*
   2.297 - * Class:     com_aurellem_send_AudioSend
   2.298 - * Method:    ngetSamples
   2.299 - * Signature: (JLjava/nio/ByteBuffer;III)V
   2.300 - */
   2.301 -JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ngetSamples
   2.302 -(JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position, 
   2.303 - jint samples, jint n){
   2.304 -  UNUSED(clazz);  
   2.305 -
   2.306 -  ALvoid *buffer_address = 
   2.307 -    ((ALbyte *)(((char*)(*env)->GetDirectBufferAddress(env, buffer)) + position));
   2.308 -  ALCdevice *recorder = (ALCdevice*) ((intptr_t)device);
   2.309 -  send_data *data = (send_data*)recorder->ExtraData;
   2.310 -  if ((ALuint)n > data->numContexts){return;}
   2.311 -  
   2.312 -  //printf("Want %d samples for listener %d\n", samples, n);
   2.313 -  //printf("Device's format type is %d bytes per sample,\n", 
   2.314 -  //  BytesFromDevFmt(recorder->FmtType));
   2.315 -  //printf("and it has %d channels, making for %d requested bytes\n", 
   2.316 -  //	 recorder->NumChan, 
   2.317 -  //	 BytesFromDevFmt(recorder->FmtType) * recorder->NumChan * samples);
   2.318 -
   2.319 -  memcpy(buffer_address, data->contexts[n]->renderBuffer, 
   2.320 -	 BytesFromDevFmt(recorder->FmtType) * recorder->NumChan * samples);
   2.321 -  //samples*sizeof(ALfloat));
   2.322 -}
   2.323 -
   2.324 -/*
   2.325 - * Class:     com_aurellem_send_AudioSend
   2.326 - * Method:    naddListener
   2.327 - * Signature: (J)V
   2.328 - */
   2.329 -JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_naddListener
   2.330 -(JNIEnv *env, jclass clazz, jlong device){
   2.331 -  UNUSED(env); UNUSED(clazz);
   2.332 -  //printf("creating new context via naddListener\n");
   2.333 -  ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
   2.334 -  ALCcontext *new = alcCreateContext(Device, NULL);
   2.335 -  addContext(Device, new);
   2.336 -}
   2.337 -
   2.338 -/*
   2.339 - * Class:     com_aurellem_send_AudioSend
   2.340 - * Method:    nsetNthListener3f
   2.341 - * Signature: (IFFFJI)V
   2.342 - */
   2.343 -JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListener3f
   2.344 -  (JNIEnv *env, jclass clazz, jint param, 
   2.345 -   jfloat v1, jfloat v2, jfloat v3, jlong device, jint contextNum){
   2.346 -  UNUSED(env);UNUSED(clazz);
   2.347 -
   2.348 -  ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
   2.349 -  send_data *data = (send_data*)Device->ExtraData;
   2.350 -  
   2.351 -  ALCcontext *current = alcGetCurrentContext();
   2.352 -  if ((ALuint)contextNum > data->numContexts){return;}
   2.353 -  alcMakeContextCurrent(data->contexts[contextNum]->ctx);
   2.354 -  alListener3f(param, v1, v2, v3);
   2.355 -  alcMakeContextCurrent(current);
   2.356 -}
   2.357 -
   2.358 -/*
   2.359 - * Class:     com_aurellem_send_AudioSend
   2.360 - * Method:    nsetNthListenerf
   2.361 - * Signature: (IFJI)V
   2.362 - */
   2.363 -JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListenerf
   2.364 -(JNIEnv *env, jclass clazz, jint param, jfloat v1, jlong device, 
   2.365 - jint contextNum){
   2.366 -
   2.367 -  UNUSED(env);UNUSED(clazz);
   2.368 -  
   2.369 -  ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
   2.370 -  send_data *data = (send_data*)Device->ExtraData;
   2.371 -  
   2.372 -  ALCcontext *current = alcGetCurrentContext();
   2.373 -  if ((ALuint)contextNum > data->numContexts){return;}
   2.374 -  alcMakeContextCurrent(data->contexts[contextNum]->ctx);
   2.375 -  alListenerf(param, v1);
   2.376 -  alcMakeContextCurrent(current);
   2.377 -}
   2.378 -
   2.379 -/*
   2.380 - * Class:     com_aurellem_send_AudioSend
   2.381 - * Method:    ninitDevice
   2.382 - * Signature: (J)V
   2.383 - */                     
   2.384 -JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ninitDevice
   2.385 -(JNIEnv *env, jclass clazz, jlong device){
   2.386 -  UNUSED(env);UNUSED(clazz);
   2.387 -  
   2.388 -  ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
   2.389 -  init(Device);
   2.390 -
   2.391 -}
   2.392 -
   2.393 -
   2.394 -/*
   2.395 - * Class:     com_aurellem_send_AudioSend
   2.396 - * Method:    ngetAudioFormat
   2.397 - * Signature: (J)Ljavax/sound/sampled/AudioFormat;
   2.398 - */
   2.399 -JNIEXPORT jobject JNICALL Java_com_aurellem_send_AudioSend_ngetAudioFormat
   2.400 -(JNIEnv *env, jclass clazz, jlong device){
   2.401 -  UNUSED(clazz);
   2.402 -  jclass AudioFormatClass = 
   2.403 -    (*env)->FindClass(env, "javax/sound/sampled/AudioFormat");
   2.404 -  jmethodID AudioFormatConstructor = 
   2.405 -    (*env)->GetMethodID(env, AudioFormatClass, "<init>", "(FIIZZ)V");
   2.406 -  
   2.407 -  ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
   2.408 -
   2.409 -  //float frequency
   2.410 -
   2.411 -  int isSigned;
   2.412 -  switch (Device->FmtType)
   2.413 -    {
   2.414 -    case DevFmtUByte: 
   2.415 -    case DevFmtUShort: isSigned = 0; break;  
   2.416 -    default : isSigned = 1;   
   2.417 -    }
   2.418 -  float frequency = Device->Frequency;
   2.419 -  int bitsPerFrame = (8 * BytesFromDevFmt(Device->FmtType));
   2.420 -  int channels = Device->NumChan;
   2.421 -
   2.422 -
   2.423 -  //printf("freq = %f, bpf = %d, channels = %d, signed? = %d\n",
   2.424 -  //	 frequency, bitsPerFrame, channels, isSigned);
   2.425 -
   2.426 -  jobject format = (*env)->
   2.427 -    NewObject(
   2.428 -	      env,AudioFormatClass,AudioFormatConstructor,
   2.429 -	      frequency,
   2.430 -	      bitsPerFrame,
   2.431 -	      channels,
   2.432 -	      isSigned,
   2.433 -	      0);
   2.434 -  return format;
   2.435 -}
   2.436 -
   2.437 -
   2.438 -
   2.439 -////////////////////   Device Initilization / Management
   2.440 -
   2.441 -static const ALCchar sendDevice[] = "Multiple Audio Send";
   2.442 -
   2.443 -static ALCboolean send_open_playback(ALCdevice *device, 
   2.444 - const ALCchar *deviceName)
   2.445 -{
   2.446 -  send_data *data;
   2.447 -  // stop any buffering for stdout, so that I can 
   2.448 -  // see the printf statements in my terminal immediatley
   2.449 -  setbuf(stdout, NULL);
   2.450 -
   2.451 -  if(!deviceName)
   2.452 -    deviceName = sendDevice;
   2.453 -  else if(strcmp(deviceName, sendDevice) != 0)
   2.454 -    return ALC_FALSE;
   2.455 -  data = (send_data*)calloc(1, sizeof(*data));
   2.456 -  device->szDeviceName = strdup(deviceName);
   2.457 -  device->ExtraData = data;
   2.458 -  return ALC_TRUE;
   2.459 -}
   2.460 -
   2.461 -static void send_close_playback(ALCdevice *device)
   2.462 -{
   2.463 -  send_data *data = (send_data*)device->ExtraData;
   2.464 -  alcMakeContextCurrent(NULL);
   2.465 -  ALuint i;
   2.466 -  // Destroy all slave contexts. LWJGL will take care of 
   2.467 -  // its own context.
   2.468 -  for (i = 1; i < data->numContexts; i++){
   2.469 -    context_data *ctxData = data->contexts[i];
   2.470 -    alcDestroyContext(ctxData->ctx);
   2.471 -    free(ctxData->renderBuffer);
   2.472 -    free(ctxData);
   2.473 -  }
   2.474 -  free(data);
   2.475 -  device->ExtraData = NULL;
   2.476 -}
   2.477 -
   2.478 -static ALCboolean send_reset_playback(ALCdevice *device)
   2.479 -{
   2.480 -  SetDefaultWFXChannelOrder(device);
   2.481 -  return ALC_TRUE;
   2.482 -}
   2.483 -
   2.484 -static void send_stop_playback(ALCdevice *Device){
   2.485 -  UNUSED(Device);
   2.486 -}
   2.487 -
   2.488 -static const BackendFuncs send_funcs = {
   2.489 -  send_open_playback,
   2.490 -  send_close_playback,
   2.491 -  send_reset_playback,
   2.492 -  send_stop_playback,
   2.493 -  NULL,
   2.494 -  NULL,  /* These would be filled with functions to    */
   2.495 -  NULL,  /* handle capturing audio if we we into that  */
   2.496 -  NULL,  /* sort of thing...                           */
   2.497 -  NULL,
   2.498 -  NULL
   2.499 -};
   2.500 -
   2.501 -ALCboolean alc_send_init(BackendFuncs *func_list){
   2.502 -  *func_list = send_funcs;
   2.503 -  return ALC_TRUE;
   2.504 -}
   2.505 -
   2.506 -void alc_send_deinit(void){}
   2.507 -
   2.508 -void alc_send_probe(enum DevProbe type)
   2.509 -{
   2.510 -  switch(type)
   2.511 -    {
   2.512 -    case DEVICE_PROBE:
   2.513 -      AppendDeviceList(sendDevice);
   2.514 -      break;
   2.515 -    case ALL_DEVICE_PROBE:
   2.516 -      AppendAllDeviceList(sendDevice);
   2.517 -      break;
   2.518 -    case CAPTURE_DEVICE_PROBE:
   2.519 -      break;
   2.520 -    }
   2.521 -}