diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Alc/utils.c	Tue Oct 25 13:02:31 2011 -0700
     1.3 @@ -0,0 +1,123 @@
     1.4 +void pauseAllSources(ALCcontext *ctx){
     1.5 +  ALCcontext *current = alcGetCurrentContext();
     1.6 +  alcMakeContextCurrent(ctx);
     1.7 +  ALsource **src, **src_end;
     1.8 +  src     = ctx->ActiveSources;
     1.9 +  src_end = src + ctx->ActiveSourceCount;
    1.10 +  while(src != src_end){
    1.11 +    if (AL_PLAYING == (*src)->state){
    1.12 +    //if (AL_TRUE){
    1.13 +      ALuint source_id = (*src)->source;
    1.14 +      //printf("pausing ONE source\n");
    1.15 +      alSourcePause(source_id);
    1.16 +    }
    1.17 +    src++;
    1.18 +  }
    1.19 +  alcMakeContextCurrent(current);
    1.20 +}
    1.21 +
    1.22 +
    1.23 +#define RUNONLY(n)				\
    1.24 +  {static int __runonce = n;			\
    1.25 +    if (__runonce-- <= 0){__runonce = 0;return;}}
    1.26 +
    1.27 +#define RUNAT(n)				\
    1.28 +  {static int __runat = n;			\
    1.29 +    if (0 != __runat--){return;}}
    1.30 +
    1.31 +
    1.32 +#define DsyncSourcei(sourceID1, sourceID2, ctx1, ctx2, param)	\
    1.33 +  {/*printf("synci : " #param "\n");*/				\
    1.34 +    syncSourcei(sourceID1, sourceID2, ctx1, ctx2, param);}
    1.35 +
    1.36 +#define DsyncSourcef(sourceID1, sourceID2, ctx1, ctx2, param)	\
    1.37 +  {/*printf("syncf : " #param "\n");*/				\
    1.38 +    syncSourcef(sourceID1, sourceID2, ctx1, ctx2, param);}
    1.39 +
    1.40 +#define DsyncSource3i(sourceID1, sourceID2, ctx1, ctx2, param)	\
    1.41 +  {/*printf("sync3i : " #param "\n");*/				\
    1.42 +    syncSource3i(sourceID1, sourceID2, ctx1, ctx2, param);}
    1.43 +
    1.44 +#define DsyncSource3f(sourceID1, sourceID2, ctx1, ctx2, param)	\
    1.45 +  {/*printf("sync3f : " #param "\n");*/				\
    1.46 +    syncSource3f(sourceID1, sourceID2, ctx1, ctx2, param);}
    1.47 +
    1.48 +void printError(void){
    1.49 +  ALenum error = alGetError();
    1.50 +  printf("%s\n", GetALCErrorString(error));
    1.51 +  printf("%s\n", GetALErrorString(error));
    1.52 +}
    1.53 +
    1.54 +
    1.55 +
    1.56 +char* GetALCErrorString(ALenum err)
    1.57 +{
    1.58 +  switch(err)
    1.59 +    {
    1.60 +    case ALC_NO_ERROR:
    1.61 +      return "AL_NO_ERROR";
    1.62 +      break;
    1.63 +
    1.64 +    case ALC_INVALID_DEVICE:
    1.65 +      return "ALC_INVALID_DEVICE";
    1.66 +      break;
    1.67 +
    1.68 +    case ALC_INVALID_CONTEXT:
    1.69 +      return "ALC_INVALID_CONTEXT";
    1.70 +      break;
    1.71 +
    1.72 +    case ALC_INVALID_ENUM:
    1.73 +      return "ALC_INVALID_ENUM";
    1.74 +      break;
    1.75 +
    1.76 +    case ALC_INVALID_VALUE:
    1.77 +      return "ALC_INVALID_VALUE";
    1.78 +      break;
    1.79 +
    1.80 +    case ALC_OUT_OF_MEMORY:
    1.81 +      return "ALC_OUT_OF_MEMORY";
    1.82 +      break;
    1.83 +    };
    1.84 +  return "UNknown error.";
    1.85 +}
    1.86 +
    1.87 +
    1.88 +
    1.89 +
    1.90 +
    1.91 +
    1.92 +
    1.93 +char* GetALErrorString(ALenum err)
    1.94 +{
    1.95 +  switch(err)
    1.96 +    {
    1.97 +    case AL_NO_ERROR:
    1.98 +      return "AL_NO_ERROR";
    1.99 +      break;
   1.100 +
   1.101 +    case AL_INVALID_NAME:
   1.102 +      return "AL_INVALID_NAME";
   1.103 +      break;
   1.104 +
   1.105 +    case AL_INVALID_ENUM:
   1.106 +      return "AL_INVALID_ENUM";
   1.107 +      break;
   1.108 +
   1.109 +    case AL_INVALID_VALUE:
   1.110 +      return "AL_INVALID_VALUE";
   1.111 +      break;
   1.112 +
   1.113 +    case AL_INVALID_OPERATION:
   1.114 +      return "AL_INVALID_OPERATION";
   1.115 +      break;
   1.116 +
   1.117 +    case AL_OUT_OF_MEMORY:
   1.118 +      return "AL_OUT_OF_MEMORY";
   1.119 +      break;
   1.120 +    };
   1.121 +  return "UNknown error.";
   1.122 +}
   1.123 +
   1.124 +
   1.125 +
   1.126 +