Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize pygame mixer before use #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NetSpida
Copy link

@NetSpida NetSpida commented Aug 4, 2023

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

@adangert
Copy link
Owner

adangert commented Aug 4, 2023

Thanks! I'll test these soon

@adangert
Copy link
Owner

adangert commented Aug 6, 2023

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.

@DrDecagon
Copy link
Contributor

DrDecagon commented Aug 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pygame.error: mixer not initialized
3 participants