openalbridge/ssound.c
changeset 2454 c8b1fb10003c
parent 2446 cbb3af76bcc0
child 2468 0b62498c201a
equal deleted inserted replaced
2453:fdb76012b688 2454:c8b1fb10003c
    23 extern ALuint sources[MAX_SOURCES];
    23 extern ALuint sources[MAX_SOURCES];
    24 extern const ALfloat NV[3];
    24 extern const ALfloat NV[3];
    25 extern const ALfloat LO[6];
    25 extern const ALfloat LO[6];
    26 
    26 
    27 extern char *prog;
    27 extern char *prog;
    28 
       
    29 /*SSOUND STUFF HERE*/
       
    30 
    28 
    31 char SSound_load (SSound_t* pSound, const char* cFilename) {
    29 char SSound_load (SSound_t* pSound, const char* cFilename) {
    32         uint32_t magic;
    30         uint32_t magic;
    33         ALenum format;
    31         ALenum format;
    34         ALsizei bitsize, freq;
    32         ALsizei bitsize, freq;
    86 
    84 
    87 void SSound_close(SSound_t* pSound)
    85 void SSound_close(SSound_t* pSound)
    88 {
    86 {
    89         SSound_stop(pSound);
    87         SSound_stop(pSound);
    90         alDeleteBuffers(1, &pSound->Buffer);
    88         alDeleteBuffers(1, &pSound->Buffer);
       
    89         return;
    91 }
    90 }
    92 
    91 
    93 void SSound_play(SSound_t* pSound, const char bLoop) {
    92 void SSound_play(SSound_t* pSound, const char bLoop) {
    94         int i;
    93         int i;
    95         
    94         
   136                 fprintf(stderr, "CSound: SourcePlay error 0x%4x in source %d\n", i, pSound->source);
   135                 fprintf(stderr, "CSound: SourcePlay error 0x%4x in source %d\n", i, pSound->source);
   137         }
   136         }
   138 #ifdef DEBUG
   137 #ifdef DEBUG
   139         fprintf(stderr, "play %s%s [%d]\n", pSound->Filename, bLoop ? " forever" : " once", pSound->source);
   138         fprintf(stderr, "play %s%s [%d]\n", pSound->Filename, bLoop ? " forever" : " once", pSound->source);
   140 #endif
   139 #endif
       
   140         usleep(0);
       
   141         return;
   141 }
   142 }
   142 
   143 
   143 void SSound_pause(const SSound_t* pSound) {
   144 void SSound_pause(const SSound_t* pSound) {
   144         if(pSound->source == -1) // not playing
   145         if(pSound->source == -1) // not playing
   145                 return;
   146                 return;
   146         alSourcePause(sources[pSound->source]);
   147         alSourcePause(sources[pSound->source]);
   147 #ifdef DEBUG
   148 #ifdef DEBUG
   148         fprintf(stderr, "pause %s\n", pSound->Filename);
   149         fprintf(stderr, "pause %s\n", pSound->Filename);
   149 #endif
   150 #endif
       
   151         return;
   150 }
   152 }
   151 
   153 
   152 void SSound_continue(const SSound_t* pSound) {
   154 void SSound_continue(const SSound_t* pSound) {
   153         if(pSound->source == -1) // not playing
   155         if(pSound->source == -1) // not playing
   154                 return;
   156                 return;
   155         alSourcePlay(sources[pSound->source]);
   157         alSourcePlay(sources[pSound->source]);
   156 #ifdef DEBUG
   158 #ifdef DEBUG
   157         fprintf(stderr, "pause %s\n", pSound->Filename);
   159         fprintf(stderr, "pause %s\n", pSound->Filename);
   158 #endif
   160 #endif
       
   161         return;
   159 }
   162 }
   160 
   163 
   161 void SSound_stop(SSound_t* pSound) {
   164 void SSound_stop(SSound_t* pSound) {
   162         if(pSound->source == -1) // not playing
   165         if(pSound->source == -1) // not playing
   163                 return;
   166                 return;
   164         alSourceStop(sources[pSound->source]);
   167         alSourceStop(sources[pSound->source]);
   165         pSound->source = -1;
   168         pSound->source = -1;
   166 #ifdef DEBUG
   169 #ifdef DEBUG
   167         fprintf(stderr, "stop %s\n", pSound->Filename);
   170         fprintf(stderr, "stop %s\n", pSound->Filename);
   168 #endif
   171 #endif
       
   172         return;
   169 }
   173 }
   170 
   174 
   171 void SSound_volume(const SSound_t* pSound, const float fPercentage) {
   175 void SSound_volume(const SSound_t* pSound, const float fPercentage) {
   172         if(pSound->source == -1) // not playing
   176         if(pSound->source == -1) // not playing
   173                 return;
   177                 return;
   174         alSourcef(sources[pSound->source], AL_GAIN, fPercentage);
   178         alSourcef(sources[pSound->source], AL_GAIN, fPercentage);
       
   179         return;
   175 }    
   180 }