LWJGL Forum

Programming => OpenAL => Topic started by: Dongalor on September 28, 2010, 15:36:42

Title: Distortion after several hours
Post by: Dongalor on September 28, 2010, 15:36:42
Hi ,

I'm developing a game using lwgl and I've a issue with sounds. I can load and play perfectly all the sounds, but after several hours playing (6 aprox), all the sounds are played with a big distortion.  Any clues of what is going on here? Why the sounds are played well but always after 6 hours are played with distortion?

Thanks in advance.
Title: Re: Distortion after several hours
Post by: Matzon on September 30, 2010, 09:51:30
are you using ALSA by any chance?
There have been some issues with that - after playing between 2 and 4 billion samples :)
Title: Re: Distortion after several hours
Post by: Dongalor on September 30, 2010, 11:15:34
Yes, I'm using ALSA. (bad news for me??  ???)

the distortion appears after 6 hours (aprox), not enough time to play 2 bilion samples ( if with a sample you mean a .wav file).  Maybe I'm having some memory leaks after 6 hours and alsa just get crazy :)

Thanks for the reply
Title: Re: Distortion after several hours
Post by: Matzon on September 30, 2010, 12:29:40
I was told that there is an integer overflow in alsa - whether or not that is the particular issue you're seeing, I do not know. But I suggest trying OSS for 6 hours too and see if it still happens :)
Title: Re: Distortion after several hours
Post by: Dongalor on October 01, 2010, 07:28:16
Hi again,

I've made some test, but now with the "space invaders" source i've found inside lwjgl-source-2.5. I added some new lines in the main loop :


Code: [Select]
while (Game.gameRunning) {
      // clear screen
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();

      // let subsystem paint
      frameRendering();

      // update window contents
      Display.update();
    if (System.currentTimeMillis() > lastSoundTime+35000) {
        lastSoundTime = System.currentTimeMillis();
        soundManager.playSound(SOUND_TEST);
      }
    }

Adding the sound  with
Code: [Select]
SOUND_TEST   = soundManager.addSound("test.wav");

The goal of the test is to play a sound via the soundManager of space invaders. After 6 hours..... distortion again :(






Title: Re: Distortion after several hours
Post by: Matzon on October 01, 2010, 08:35:52
Unless you have changed to OSS in the mean time, this test doesn't really prove anything new :/
Title: Re: Distortion after several hours
Post by: Dongalor on October 08, 2010, 11:20:41
I forgot to post the results  :P

With OSS everithing works fine. Thanks for the advice!
Title: Re: Distortion after several hours
Post by: Matzon on October 08, 2010, 12:26:22
ok, so we can conclude:
a) dont use ALSA if playing for more than 6 hours
b) dont play for more than 6 hours :)

thanks for responding back
Title: Re: Distortion after several hours
Post by: alepao on November 09, 2015, 17:58:02
Hi,


did you check if the card's alsa hw_params matched with the sound output you set up when initializing the audio.
I had the same problem when I was developing a game for a linux board.
This .asoundrc config file solved the issue for me (I was playing at 44100Hz):

pcm.!default {
type rate
slave {
pcm "plughw:0,0"
rate 44100
}
}

Just put it on your home dir.
There was a sort of growing drift due to unmatched sampling freq between the program and the card's ha_params.
Maybe it's a alsa bug...