示例#1
0
 @Override
 public long loop(float volume) {
   if (audio.noDevice) return 0;
   int sourceID = audio.obtainSource(false);
   if (sourceID == -1) return -1;
   long soundId = audio.getSoundId(sourceID);
   alSourcei(sourceID, AL_BUFFER, bufferID);
   alSourcei(sourceID, AL_LOOPING, AL_TRUE);
   alSourcef(sourceID, AL_GAIN, volume);
   alSourcePlay(sourceID);
   return soundId;
 }
示例#2
0
 public long play(float volume) {
   if (audio.noDevice) return 0;
   int sourceID = audio.obtainSource(false);
   if (sourceID == -1) {
     // Attempt to recover by stopping the least recently played sound
     audio.retain(this, true);
     sourceID = audio.obtainSource(false);
   } else audio.retain(this, false);
   // In case it still didn't work
   if (sourceID == -1) return -1;
   long soundId = audio.getSoundId(sourceID);
   alSourcei(sourceID, AL_BUFFER, bufferID);
   alSourcei(sourceID, AL_LOOPING, AL_FALSE);
   alSourcef(sourceID, AL_GAIN, volume);
   alSourcePlay(sourceID);
   return soundId;
 }