annotate Alc/backends/send.c @ 33:3caceef436ea tip

formatting for web
author Robert McIntyre <rlm@mit.edu>
date Sat, 11 Feb 2012 12:25:55 -0700
parents f4c7260d397a
children
rev   line source
rlm@23 1
rlm@23 2 #include "config.h"
rlm@23 3 #include <stdlib.h>
rlm@23 4 #include "alMain.h"
rlm@23 5 #include "AL/al.h"
rlm@23 6 #include "AL/alc.h"
rlm@23 7 #include "alSource.h"
rlm@23 8 #include <jni.h>
rlm@23 9
rlm@23 10 //////////////////// Summary
rlm@23 11
rlm@23 12 struct send_data;
rlm@23 13 struct context_data;
rlm@23 14
rlm@23 15 static void addContext(ALCdevice *, ALCcontext *);
rlm@23 16 static void syncContexts(ALCcontext *master, ALCcontext *slave);
rlm@23 17 static void syncSources(ALsource *master, ALsource *slave,
rlm@23 18 ALCcontext *masterCtx, ALCcontext *slaveCtx);
rlm@23 19
rlm@23 20 static void syncSourcei(ALuint master, ALuint slave,
rlm@23 21 ALCcontext *masterCtx, ALCcontext *ctx2, ALenum param);
rlm@23 22 static void syncSourcef(ALuint master, ALuint slave,
rlm@23 23 ALCcontext *masterCtx, ALCcontext *ctx2, ALenum param);
rlm@23 24 static void syncSource3f(ALuint master, ALuint slave,
rlm@23 25 ALCcontext *masterCtx, ALCcontext *ctx2, ALenum param);
rlm@23 26
rlm@23 27 static void swapInContext(ALCdevice *, struct context_data *);
rlm@23 28 static void saveContext(ALCdevice *, struct context_data *);
rlm@23 29 static void limitContext(ALCdevice *, ALCcontext *);
rlm@23 30 static void unLimitContext(ALCdevice *);
rlm@23 31
rlm@23 32 static void init(ALCdevice *);
rlm@23 33 static void renderData(ALCdevice *, int samples);
rlm@23 34
rlm@23 35 #define UNUSED(x) (void)(x)
rlm@23 36 //////////////////// State
rlm@23 37
rlm@23 38 typedef struct context_data {
rlm@23 39 ALfloat ClickRemoval[MAXCHANNELS];
rlm@23 40 ALfloat PendingClicks[MAXCHANNELS];
rlm@23 41 ALvoid *renderBuffer;
rlm@23 42 ALCcontext *ctx;
rlm@23 43 } context_data;
rlm@23 44
rlm@23 45 typedef struct send_data {
rlm@23 46 ALuint size;
rlm@23 47 context_data **contexts;
rlm@23 48 ALuint numContexts;
rlm@23 49 ALuint maxContexts;
rlm@23 50 } send_data;
rlm@23 51 //////////////////// Context Creation / Synchronization
rlm@23 52
rlm@23 53 #define _MAKE_SYNC(NAME, INIT_EXPR, GET_EXPR, SET_EXPR) \
rlm@23 54 void NAME (ALuint sourceID1, ALuint sourceID2, \
rlm@23 55 ALCcontext *ctx1, ALCcontext *ctx2, \
rlm@23 56 ALenum param){ \
rlm@23 57 INIT_EXPR; \
rlm@23 58 ALCcontext *current = alcGetCurrentContext(); \
rlm@23 59 alcMakeContextCurrent(ctx1); \
rlm@23 60 GET_EXPR; \
rlm@23 61 alcMakeContextCurrent(ctx2); \
rlm@23 62 SET_EXPR; \
rlm@23 63 alcMakeContextCurrent(current); \
rlm@23 64 }
rlm@23 65
rlm@23 66 #define MAKE_SYNC(NAME, TYPE, GET, SET) \
rlm@23 67 _MAKE_SYNC(NAME, \
rlm@23 68 TYPE value, \
rlm@23 69 GET(sourceID1, param, &value), \
rlm@23 70 SET(sourceID2, param, value))
rlm@23 71
rlm@23 72 #define MAKE_SYNC3(NAME, TYPE, GET, SET) \
rlm@23 73 _MAKE_SYNC(NAME, \
rlm@23 74 TYPE value1; TYPE value2; TYPE value3;, \
rlm@23 75 GET(sourceID1, param, &value1, &value2, &value3), \
rlm@23 76 SET(sourceID2, param, value1, value2, value3))
rlm@23 77
rlm@23 78 MAKE_SYNC( syncSourcei, ALint, alGetSourcei, alSourcei);
rlm@23 79 MAKE_SYNC( syncSourcef, ALfloat, alGetSourcef, alSourcef);
rlm@23 80 MAKE_SYNC3(syncSource3i, ALint, alGetSource3i, alSource3i);
rlm@23 81 MAKE_SYNC3(syncSource3f, ALfloat, alGetSource3f, alSource3f);
rlm@23 82
rlm@23 83 void syncSources(ALsource *masterSource, ALsource *slaveSource,
rlm@23 84 ALCcontext *masterCtx, ALCcontext *slaveCtx){
rlm@23 85 ALuint master = masterSource->source;
rlm@23 86 ALuint slave = slaveSource->source;
rlm@23 87 ALCcontext *current = alcGetCurrentContext();
rlm@23 88
rlm@23 89 syncSourcef(master,slave,masterCtx,slaveCtx,AL_PITCH);
rlm@23 90 syncSourcef(master,slave,masterCtx,slaveCtx,AL_GAIN);
rlm@23 91 syncSourcef(master,slave,masterCtx,slaveCtx,AL_MAX_DISTANCE);
rlm@23 92 syncSourcef(master,slave,masterCtx,slaveCtx,AL_ROLLOFF_FACTOR);
rlm@23 93 syncSourcef(master,slave,masterCtx,slaveCtx,AL_REFERENCE_DISTANCE);
rlm@23 94 syncSourcef(master,slave,masterCtx,slaveCtx,AL_MIN_GAIN);
rlm@23 95 syncSourcef(master,slave,masterCtx,slaveCtx,AL_MAX_GAIN);
rlm@23 96 syncSourcef(master,slave,masterCtx,slaveCtx,AL_CONE_OUTER_GAIN);
rlm@23 97 syncSourcef(master,slave,masterCtx,slaveCtx,AL_CONE_INNER_ANGLE);
rlm@23 98 syncSourcef(master,slave,masterCtx,slaveCtx,AL_CONE_OUTER_ANGLE);
rlm@23 99 syncSourcef(master,slave,masterCtx,slaveCtx,AL_SEC_OFFSET);
rlm@23 100 syncSourcef(master,slave,masterCtx,slaveCtx,AL_SAMPLE_OFFSET);
rlm@23 101 syncSourcef(master,slave,masterCtx,slaveCtx,AL_BYTE_OFFSET);
rlm@23 102
rlm@23 103 syncSource3f(master,slave,masterCtx,slaveCtx,AL_POSITION);
rlm@23 104 syncSource3f(master,slave,masterCtx,slaveCtx,AL_VELOCITY);
rlm@23 105 syncSource3f(master,slave,masterCtx,slaveCtx,AL_DIRECTION);
rlm@23 106
rlm@23 107 syncSourcei(master,slave,masterCtx,slaveCtx,AL_SOURCE_RELATIVE);
rlm@23 108 syncSourcei(master,slave,masterCtx,slaveCtx,AL_LOOPING);
rlm@23 109
rlm@23 110 alcMakeContextCurrent(masterCtx);
rlm@23 111 ALint source_type;
rlm@23 112 alGetSourcei(master, AL_SOURCE_TYPE, &source_type);
rlm@23 113
rlm@23 114 // Only static sources are currently synchronized!
rlm@23 115 if (AL_STATIC == source_type){
rlm@23 116 ALint master_buffer;
rlm@23 117 ALint slave_buffer;
rlm@23 118 alGetSourcei(master, AL_BUFFER, &master_buffer);
rlm@23 119 alcMakeContextCurrent(slaveCtx);
rlm@23 120 alGetSourcei(slave, AL_BUFFER, &slave_buffer);
rlm@23 121 if (master_buffer != slave_buffer){
rlm@23 122 alSourcei(slave, AL_BUFFER, master_buffer);
rlm@23 123 }
rlm@23 124 }
rlm@23 125
rlm@23 126 // Synchronize the state of the two sources.
rlm@23 127 alcMakeContextCurrent(masterCtx);
rlm@23 128 ALint masterState;
rlm@23 129 ALint slaveState;
rlm@23 130
rlm@23 131 alGetSourcei(master, AL_SOURCE_STATE, &masterState);
rlm@23 132 alcMakeContextCurrent(slaveCtx);
rlm@23 133 alGetSourcei(slave, AL_SOURCE_STATE, &slaveState);
rlm@23 134
rlm@23 135 if (masterState != slaveState){
rlm@23 136 switch (masterState){
rlm@23 137 case AL_INITIAL : alSourceRewind(slave); break;
rlm@23 138 case AL_PLAYING : alSourcePlay(slave); break;
rlm@23 139 case AL_PAUSED : alSourcePause(slave); break;
rlm@23 140 case AL_STOPPED : alSourceStop(slave); break;
rlm@23 141 }
rlm@23 142 }
rlm@23 143 // Restore whatever context was previously active.
rlm@23 144 alcMakeContextCurrent(current);
rlm@23 145 }
rlm@23 146 void syncContexts(ALCcontext *master, ALCcontext *slave){
rlm@23 147 /* If there aren't sufficient sources in slave to mirror
rlm@23 148 the sources in master, create them. */
rlm@23 149 ALCcontext *current = alcGetCurrentContext();
rlm@23 150
rlm@23 151 UIntMap *masterSourceMap = &(master->SourceMap);
rlm@23 152 UIntMap *slaveSourceMap = &(slave->SourceMap);
rlm@23 153 ALuint numMasterSources = masterSourceMap->size;
rlm@23 154 ALuint numSlaveSources = slaveSourceMap->size;
rlm@23 155
rlm@23 156 alcMakeContextCurrent(slave);
rlm@23 157 if (numSlaveSources < numMasterSources){
rlm@23 158 ALuint numMissingSources = numMasterSources - numSlaveSources;
rlm@23 159 ALuint newSources[numMissingSources];
rlm@23 160 alGenSources(numMissingSources, newSources);
rlm@23 161 }
rlm@23 162
rlm@23 163 /* Now, slave is guaranteed to have at least as many sources
rlm@23 164 as master. Sync each source from master to the corresponding
rlm@23 165 source in slave. */
rlm@23 166 int i;
rlm@23 167 for(i = 0; i < masterSourceMap->size; i++){
rlm@23 168 syncSources((ALsource*)masterSourceMap->array[i].value,
rlm@23 169 (ALsource*)slaveSourceMap->array[i].value,
rlm@23 170 master, slave);
rlm@23 171 }
rlm@23 172 alcMakeContextCurrent(current);
rlm@23 173 }
rlm@23 174 static void addContext(ALCdevice *Device, ALCcontext *context){
rlm@23 175 send_data *data = (send_data*)Device->ExtraData;
rlm@23 176 // expand array if necessary
rlm@23 177 if (data->numContexts >= data->maxContexts){
rlm@23 178 ALuint newMaxContexts = data->maxContexts*2 + 1;
rlm@23 179 data->contexts = realloc(data->contexts, newMaxContexts*sizeof(context_data));
rlm@23 180 data->maxContexts = newMaxContexts;
rlm@23 181 }
rlm@23 182 // create context_data and add it to the main array
rlm@23 183 context_data *ctxData;
rlm@23 184 ctxData = (context_data*)calloc(1, sizeof(*ctxData));
rlm@23 185 ctxData->renderBuffer =
rlm@23 186 malloc(BytesFromDevFmt(Device->FmtType) *
rlm@23 187 Device->NumChan * Device->UpdateSize);
rlm@23 188 ctxData->ctx = context;
rlm@23 189
rlm@23 190 data->contexts[data->numContexts] = ctxData;
rlm@23 191 data->numContexts++;
rlm@23 192 }
rlm@23 193 //////////////////// Context Switching
rlm@23 194
rlm@23 195 /* A device brings along with it two pieces of state
rlm@23 196 * which have to be swapped in and out with each context.
rlm@23 197 */
rlm@23 198 static void swapInContext(ALCdevice *Device, context_data *ctxData){
rlm@23 199 memcpy(Device->ClickRemoval, ctxData->ClickRemoval, sizeof(ALfloat)*MAXCHANNELS);
rlm@23 200 memcpy(Device->PendingClicks, ctxData->PendingClicks, sizeof(ALfloat)*MAXCHANNELS);
rlm@23 201 }
rlm@23 202
rlm@23 203 static void saveContext(ALCdevice *Device, context_data *ctxData){
rlm@23 204 memcpy(ctxData->ClickRemoval, Device->ClickRemoval, sizeof(ALfloat)*MAXCHANNELS);
rlm@23 205 memcpy(ctxData->PendingClicks, Device->PendingClicks, sizeof(ALfloat)*MAXCHANNELS);
rlm@23 206 }
rlm@23 207
rlm@23 208 static ALCcontext **currentContext;
rlm@23 209 static ALuint currentNumContext;
rlm@23 210
rlm@23 211 /* By default, all contexts are rendered at once for each call to aluMixData.
rlm@23 212 * This function uses the internals of the ALCdevice struct to temporally
rlm@23 213 * cause aluMixData to only render the chosen context.
rlm@23 214 */
rlm@23 215 static void limitContext(ALCdevice *Device, ALCcontext *ctx){
rlm@23 216 currentContext = Device->Contexts;
rlm@23 217 currentNumContext = Device->NumContexts;
rlm@23 218 Device->Contexts = &ctx;
rlm@23 219 Device->NumContexts = 1;
rlm@23 220 }
rlm@23 221
rlm@23 222 static void unLimitContext(ALCdevice *Device){
rlm@23 223 Device->Contexts = currentContext;
rlm@23 224 Device->NumContexts = currentNumContext;
rlm@23 225 }
rlm@23 226 //////////////////// Main Device Loop
rlm@23 227
rlm@23 228 /* Establish the LWJGL context as the master context, which will
rlm@23 229 * be synchronized to all the slave contexts
rlm@23 230 */
rlm@23 231 static void init(ALCdevice *Device){
rlm@23 232 ALCcontext *masterContext = alcGetCurrentContext();
rlm@23 233 addContext(Device, masterContext);
rlm@23 234 }
rlm@23 235
rlm@23 236 static void renderData(ALCdevice *Device, int samples){
rlm@23 237 if(!Device->Connected){return;}
rlm@23 238 send_data *data = (send_data*)Device->ExtraData;
rlm@23 239 ALCcontext *current = alcGetCurrentContext();
rlm@23 240
rlm@23 241 ALuint i;
rlm@23 242 for (i = 1; i < data->numContexts; i++){
rlm@23 243 syncContexts(data->contexts[0]->ctx , data->contexts[i]->ctx);
rlm@23 244 }
rlm@23 245
rlm@25 246 if ((ALuint) samples > Device->UpdateSize){
rlm@23 247 printf("exceeding internal buffer size; dropping samples\n");
rlm@23 248 printf("requested %d; available %d\n", samples, Device->UpdateSize);
rlm@23 249 samples = (int) Device->UpdateSize;
rlm@23 250 }
rlm@23 251
rlm@23 252 for (i = 0; i < data->numContexts; i++){
rlm@23 253 context_data *ctxData = data->contexts[i];
rlm@23 254 ALCcontext *ctx = ctxData->ctx;
rlm@23 255 alcMakeContextCurrent(ctx);
rlm@23 256 limitContext(Device, ctx);
rlm@23 257 swapInContext(Device, ctxData);
rlm@23 258 aluMixData(Device, ctxData->renderBuffer, samples);
rlm@23 259 saveContext(Device, ctxData);
rlm@23 260 unLimitContext(Device);
rlm@23 261 }
rlm@23 262 alcMakeContextCurrent(current);
rlm@23 263 }
rlm@23 264 //////////////////// JNI Methods
rlm@23 265
rlm@23 266 #include "com_aurellem_send_AudioSend.h"
rlm@23 267
rlm@23 268 /*
rlm@23 269 * Class: com_aurellem_send_AudioSend
rlm@23 270 * Method: nstep
rlm@23 271 * Signature: (JI)V
rlm@23 272 */
rlm@23 273 JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nstep
rlm@23 274 (JNIEnv *env, jclass clazz, jlong device, jint samples){
rlm@23 275 UNUSED(env);UNUSED(clazz);UNUSED(device);
rlm@23 276 renderData((ALCdevice*)((intptr_t)device), samples);
rlm@23 277 }
rlm@23 278 /*
rlm@23 279 * Class: com_aurellem_send_AudioSend
rlm@23 280 * Method: ngetSamples
rlm@23 281 * Signature: (JLjava/nio/ByteBuffer;III)V
rlm@23 282 */
rlm@23 283 JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ngetSamples
rlm@23 284 (JNIEnv *env, jclass clazz, jlong device, jobject buffer, jint position,
rlm@23 285 jint samples, jint n){
rlm@23 286 UNUSED(clazz);
rlm@23 287
rlm@23 288 ALvoid *buffer_address =
rlm@23 289 ((ALbyte *)(((char*)(*env)->GetDirectBufferAddress(env, buffer)) + position));
rlm@23 290 ALCdevice *recorder = (ALCdevice*) ((intptr_t)device);
rlm@23 291 send_data *data = (send_data*)recorder->ExtraData;
rlm@23 292 if ((ALuint)n > data->numContexts){return;}
rlm@23 293 memcpy(buffer_address, data->contexts[n]->renderBuffer,
rlm@23 294 BytesFromDevFmt(recorder->FmtType) * recorder->NumChan * samples);
rlm@23 295 }
rlm@23 296 /*
rlm@23 297 * Class: com_aurellem_send_AudioSend
rlm@23 298 * Method: naddListener
rlm@23 299 * Signature: (J)V
rlm@23 300 */
rlm@23 301 JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_naddListener
rlm@23 302 (JNIEnv *env, jclass clazz, jlong device){
rlm@23 303 UNUSED(env); UNUSED(clazz);
rlm@23 304 //printf("creating new context via naddListener\n");
rlm@23 305 ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
rlm@23 306 ALCcontext *new = alcCreateContext(Device, NULL);
rlm@23 307 addContext(Device, new);
rlm@23 308 }
rlm@23 309
rlm@23 310 /*
rlm@23 311 * Class: com_aurellem_send_AudioSend
rlm@23 312 * Method: nsetNthListener3f
rlm@23 313 * Signature: (IFFFJI)V
rlm@23 314 */
rlm@23 315 JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListener3f
rlm@23 316 (JNIEnv *env, jclass clazz, jint param,
rlm@23 317 jfloat v1, jfloat v2, jfloat v3, jlong device, jint contextNum){
rlm@23 318 UNUSED(env);UNUSED(clazz);
rlm@23 319
rlm@23 320 ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
rlm@23 321 send_data *data = (send_data*)Device->ExtraData;
rlm@23 322
rlm@23 323 ALCcontext *current = alcGetCurrentContext();
rlm@23 324 if ((ALuint)contextNum > data->numContexts){return;}
rlm@23 325 alcMakeContextCurrent(data->contexts[contextNum]->ctx);
rlm@23 326 alListener3f(param, v1, v2, v3);
rlm@23 327 alcMakeContextCurrent(current);
rlm@23 328 }
rlm@23 329
rlm@23 330 /*
rlm@23 331 * Class: com_aurellem_send_AudioSend
rlm@23 332 * Method: nsetNthListenerf
rlm@23 333 * Signature: (IFJI)V
rlm@23 334 */
rlm@23 335 JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_nsetNthListenerf
rlm@23 336 (JNIEnv *env, jclass clazz, jint param, jfloat v1, jlong device,
rlm@23 337 jint contextNum){
rlm@23 338
rlm@23 339 UNUSED(env);UNUSED(clazz);
rlm@23 340
rlm@23 341 ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
rlm@23 342 send_data *data = (send_data*)Device->ExtraData;
rlm@23 343
rlm@23 344 ALCcontext *current = alcGetCurrentContext();
rlm@23 345 if ((ALuint)contextNum > data->numContexts){return;}
rlm@23 346 alcMakeContextCurrent(data->contexts[contextNum]->ctx);
rlm@23 347 alListenerf(param, v1);
rlm@23 348 alcMakeContextCurrent(current);
rlm@23 349 }
rlm@23 350 /*
rlm@23 351 * Class: com_aurellem_send_AudioSend
rlm@23 352 * Method: ninitDevice
rlm@23 353 * Signature: (J)V
rlm@23 354 */
rlm@23 355 JNIEXPORT void JNICALL Java_com_aurellem_send_AudioSend_ninitDevice
rlm@23 356 (JNIEnv *env, jclass clazz, jlong device){
rlm@23 357 UNUSED(env);UNUSED(clazz);
rlm@23 358 ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
rlm@23 359 init(Device);
rlm@23 360 }
rlm@23 361
rlm@23 362 /*
rlm@23 363 * Class: com_aurellem_send_AudioSend
rlm@23 364 * Method: ngetAudioFormat
rlm@23 365 * Signature: (J)Ljavax/sound/sampled/AudioFormat;
rlm@23 366 */
rlm@23 367 JNIEXPORT jobject JNICALL Java_com_aurellem_send_AudioSend_ngetAudioFormat
rlm@23 368 (JNIEnv *env, jclass clazz, jlong device){
rlm@23 369 UNUSED(clazz);
rlm@23 370 jclass AudioFormatClass =
rlm@23 371 (*env)->FindClass(env, "javax/sound/sampled/AudioFormat");
rlm@23 372 jmethodID AudioFormatConstructor =
rlm@23 373 (*env)->GetMethodID(env, AudioFormatClass, "<init>", "(FIIZZ)V");
rlm@23 374
rlm@23 375 ALCdevice *Device = (ALCdevice*) ((intptr_t)device);
rlm@23 376 int isSigned;
rlm@23 377 switch (Device->FmtType)
rlm@23 378 {
rlm@23 379 case DevFmtUByte:
rlm@23 380 case DevFmtUShort: isSigned = 0; break;
rlm@23 381 default : isSigned = 1;
rlm@23 382 }
rlm@23 383 float frequency = Device->Frequency;
rlm@23 384 int bitsPerFrame = (8 * BytesFromDevFmt(Device->FmtType));
rlm@23 385 int channels = Device->NumChan;
rlm@23 386 jobject format = (*env)->
rlm@23 387 NewObject(
rlm@23 388 env,AudioFormatClass,AudioFormatConstructor,
rlm@23 389 frequency,
rlm@23 390 bitsPerFrame,
rlm@23 391 channels,
rlm@23 392 isSigned,
rlm@23 393 0);
rlm@23 394 return format;
rlm@23 395 }
rlm@23 396 //////////////////// Device Initialization / Management
rlm@23 397
rlm@23 398 static const ALCchar sendDevice[] = "Multiple Audio Send";
rlm@23 399
rlm@23 400 static ALCboolean send_open_playback(ALCdevice *device,
rlm@23 401 const ALCchar *deviceName)
rlm@23 402 {
rlm@23 403 send_data *data;
rlm@23 404 // stop any buffering for stdout, so that I can
rlm@23 405 // see the printf statements in my terminal immediately
rlm@23 406 setbuf(stdout, NULL);
rlm@23 407
rlm@23 408 if(!deviceName)
rlm@23 409 deviceName = sendDevice;
rlm@23 410 else if(strcmp(deviceName, sendDevice) != 0)
rlm@23 411 return ALC_FALSE;
rlm@23 412 data = (send_data*)calloc(1, sizeof(*data));
rlm@23 413 device->szDeviceName = strdup(deviceName);
rlm@23 414 device->ExtraData = data;
rlm@23 415 return ALC_TRUE;
rlm@23 416 }
rlm@23 417
rlm@23 418 static void send_close_playback(ALCdevice *device)
rlm@23 419 {
rlm@23 420 send_data *data = (send_data*)device->ExtraData;
rlm@23 421 alcMakeContextCurrent(NULL);
rlm@23 422 ALuint i;
rlm@23 423 // Destroy all slave contexts. LWJGL will take care of
rlm@23 424 // its own context.
rlm@23 425 for (i = 1; i < data->numContexts; i++){
rlm@23 426 context_data *ctxData = data->contexts[i];
rlm@23 427 alcDestroyContext(ctxData->ctx);
rlm@23 428 free(ctxData->renderBuffer);
rlm@23 429 free(ctxData);
rlm@23 430 }
rlm@23 431 free(data);
rlm@23 432 device->ExtraData = NULL;
rlm@23 433 }
rlm@23 434
rlm@23 435 static ALCboolean send_reset_playback(ALCdevice *device)
rlm@23 436 {
rlm@23 437 SetDefaultWFXChannelOrder(device);
rlm@23 438 return ALC_TRUE;
rlm@23 439 }
rlm@23 440
rlm@23 441 static void send_stop_playback(ALCdevice *Device){
rlm@23 442 UNUSED(Device);
rlm@23 443 }
rlm@23 444
rlm@23 445 static const BackendFuncs send_funcs = {
rlm@23 446 send_open_playback,
rlm@23 447 send_close_playback,
rlm@23 448 send_reset_playback,
rlm@23 449 send_stop_playback,
rlm@23 450 NULL,
rlm@23 451 NULL, /* These would be filled with functions to */
rlm@23 452 NULL, /* handle capturing audio if we we into that */
rlm@23 453 NULL, /* sort of thing... */
rlm@23 454 NULL,
rlm@23 455 NULL
rlm@23 456 };
rlm@23 457
rlm@23 458 ALCboolean alc_send_init(BackendFuncs *func_list){
rlm@23 459 *func_list = send_funcs;
rlm@23 460 return ALC_TRUE;
rlm@23 461 }
rlm@23 462
rlm@23 463 void alc_send_deinit(void){}
rlm@23 464
rlm@23 465 void alc_send_probe(enum DevProbe type)
rlm@23 466 {
rlm@23 467 switch(type)
rlm@23 468 {
rlm@23 469 case DEVICE_PROBE:
rlm@23 470 AppendDeviceList(sendDevice);
rlm@23 471 break;
rlm@23 472 case ALL_DEVICE_PROBE:
rlm@23 473 AppendAllDeviceList(sendDevice);
rlm@23 474 break;
rlm@23 475 case CAPTURE_DEVICE_PROBE:
rlm@23 476 break;
rlm@23 477 }
rlm@23 478 }