annotate Alc/utils.c @ 0:f9476ff7637e

initial forking of open-al to create multiple listeners
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 13:02:31 -0700
parents
children
rev   line source
rlm@0 1 void pauseAllSources(ALCcontext *ctx){
rlm@0 2 ALCcontext *current = alcGetCurrentContext();
rlm@0 3 alcMakeContextCurrent(ctx);
rlm@0 4 ALsource **src, **src_end;
rlm@0 5 src = ctx->ActiveSources;
rlm@0 6 src_end = src + ctx->ActiveSourceCount;
rlm@0 7 while(src != src_end){
rlm@0 8 if (AL_PLAYING == (*src)->state){
rlm@0 9 //if (AL_TRUE){
rlm@0 10 ALuint source_id = (*src)->source;
rlm@0 11 //printf("pausing ONE source\n");
rlm@0 12 alSourcePause(source_id);
rlm@0 13 }
rlm@0 14 src++;
rlm@0 15 }
rlm@0 16 alcMakeContextCurrent(current);
rlm@0 17 }
rlm@0 18
rlm@0 19
rlm@0 20 #define RUNONLY(n) \
rlm@0 21 {static int __runonce = n; \
rlm@0 22 if (__runonce-- <= 0){__runonce = 0;return;}}
rlm@0 23
rlm@0 24 #define RUNAT(n) \
rlm@0 25 {static int __runat = n; \
rlm@0 26 if (0 != __runat--){return;}}
rlm@0 27
rlm@0 28
rlm@0 29 #define DsyncSourcei(sourceID1, sourceID2, ctx1, ctx2, param) \
rlm@0 30 {/*printf("synci : " #param "\n");*/ \
rlm@0 31 syncSourcei(sourceID1, sourceID2, ctx1, ctx2, param);}
rlm@0 32
rlm@0 33 #define DsyncSourcef(sourceID1, sourceID2, ctx1, ctx2, param) \
rlm@0 34 {/*printf("syncf : " #param "\n");*/ \
rlm@0 35 syncSourcef(sourceID1, sourceID2, ctx1, ctx2, param);}
rlm@0 36
rlm@0 37 #define DsyncSource3i(sourceID1, sourceID2, ctx1, ctx2, param) \
rlm@0 38 {/*printf("sync3i : " #param "\n");*/ \
rlm@0 39 syncSource3i(sourceID1, sourceID2, ctx1, ctx2, param);}
rlm@0 40
rlm@0 41 #define DsyncSource3f(sourceID1, sourceID2, ctx1, ctx2, param) \
rlm@0 42 {/*printf("sync3f : " #param "\n");*/ \
rlm@0 43 syncSource3f(sourceID1, sourceID2, ctx1, ctx2, param);}
rlm@0 44
rlm@0 45 void printError(void){
rlm@0 46 ALenum error = alGetError();
rlm@0 47 printf("%s\n", GetALCErrorString(error));
rlm@0 48 printf("%s\n", GetALErrorString(error));
rlm@0 49 }
rlm@0 50
rlm@0 51
rlm@0 52
rlm@0 53 char* GetALCErrorString(ALenum err)
rlm@0 54 {
rlm@0 55 switch(err)
rlm@0 56 {
rlm@0 57 case ALC_NO_ERROR:
rlm@0 58 return "AL_NO_ERROR";
rlm@0 59 break;
rlm@0 60
rlm@0 61 case ALC_INVALID_DEVICE:
rlm@0 62 return "ALC_INVALID_DEVICE";
rlm@0 63 break;
rlm@0 64
rlm@0 65 case ALC_INVALID_CONTEXT:
rlm@0 66 return "ALC_INVALID_CONTEXT";
rlm@0 67 break;
rlm@0 68
rlm@0 69 case ALC_INVALID_ENUM:
rlm@0 70 return "ALC_INVALID_ENUM";
rlm@0 71 break;
rlm@0 72
rlm@0 73 case ALC_INVALID_VALUE:
rlm@0 74 return "ALC_INVALID_VALUE";
rlm@0 75 break;
rlm@0 76
rlm@0 77 case ALC_OUT_OF_MEMORY:
rlm@0 78 return "ALC_OUT_OF_MEMORY";
rlm@0 79 break;
rlm@0 80 };
rlm@0 81 return "UNknown error.";
rlm@0 82 }
rlm@0 83
rlm@0 84
rlm@0 85
rlm@0 86
rlm@0 87
rlm@0 88
rlm@0 89
rlm@0 90 char* GetALErrorString(ALenum err)
rlm@0 91 {
rlm@0 92 switch(err)
rlm@0 93 {
rlm@0 94 case AL_NO_ERROR:
rlm@0 95 return "AL_NO_ERROR";
rlm@0 96 break;
rlm@0 97
rlm@0 98 case AL_INVALID_NAME:
rlm@0 99 return "AL_INVALID_NAME";
rlm@0 100 break;
rlm@0 101
rlm@0 102 case AL_INVALID_ENUM:
rlm@0 103 return "AL_INVALID_ENUM";
rlm@0 104 break;
rlm@0 105
rlm@0 106 case AL_INVALID_VALUE:
rlm@0 107 return "AL_INVALID_VALUE";
rlm@0 108 break;
rlm@0 109
rlm@0 110 case AL_INVALID_OPERATION:
rlm@0 111 return "AL_INVALID_OPERATION";
rlm@0 112 break;
rlm@0 113
rlm@0 114 case AL_OUT_OF_MEMORY:
rlm@0 115 return "AL_OUT_OF_MEMORY";
rlm@0 116 break;
rlm@0 117 };
rlm@0 118 return "UNknown error.";
rlm@0 119 }
rlm@0 120
rlm@0 121
rlm@0 122
rlm@0 123