[Openal] Playing finite looping sounds

Agustin Rubio Mingorance arubio at die.upm.es
Tue Jun 19 05:13:37 PDT 2007


Hi,

I have writen the next function to play finite looping sounds:

  void
  AudioSystem::play (int sound_id, unsigned int channel, unsigned int loop,
             string sound_name)
  {
     [....]
     //Obtained sound_id from sound_name
    if (sound_id){
      if (loop == 0) {
        alSourcei (audio_sources[channel], AL_LOOPING, AL_TRUE);
        alSourcei (audio_sources[channel], AL_BUFFER, sound_id);
      }
    else {
        ALuint source[loop];
        alSourcei (audio_sources[channel], AL_LOOPING, AL_FALSE);

        for (unsigned int i = 0; i < loop; i++) {
          source[i] = sound_id;
        }
            alSourceQueueBuffers (audio_sources[channel], loop, source);
      }
      alSourcePlay (audio_sources[channel]);
    }


When I use if with buffers created with  alutCreateBufferFromFile 
(file_str),  it works fine.
When I use an OGG file (loaded with VORBIS extension), the sound is 
played in an infinite
loop whenever loop!=1;

Am I doing something wrongly?

Thanks in advance.


More information about the Openal mailing list