JoustMania icon indicating copy to clipboard operation
JoustMania copied to clipboard

initialize pygame mixer before use

Open NetSpida opened this issue 2 years ago • 3 comments

It seems that pygame.mixer was not always initialized. Fixes #305

NetSpida avatar Aug 04 '23 22:08 NetSpida

Thanks! I'll test these soon

adangert avatar Aug 04 '23 22:08 adangert

Hi @NetSpida pygame mixer should always be initialized here: https://github.com/adangert/JoustMania/blob/master/piaudio.py#L274 and https://github.com/adangert/JoustMania/blob/master/piparty.py#L1050

I also tried changing the initialization from pygame.mixer.init(47000, -16, 2 , 4096) to pygame.mixer.init() which lists the frequency, size, channels, and buffer, and started getting a bunch of garbled audio and ALSA lib pcm.c:8545:(snd_pcm_recover) underrun occurred errors in the console.

have you tried doing a clean install of the raspberry pi OS and setup.sh? I'm not seeing this happen on my end.

adangert avatar Aug 06 '23 22:08 adangert

pygame mixer also gets initialized in update.py. Is it possible it does not release control of the device for piparty.py in some cases. If so, it could cause the pygame.error: ALSA: Couldn't open audio device: Invalid argument errors.

I tried this patch, except with pygame.mixer.init(47000, -16, 2 , 4096) instead of pygame.mixer.init() but still get errors.

DrDecagon avatar Aug 09 '23 07:08 DrDecagon