I've been playing around with pygame and my raspberry py for some time now. I just need to play a few sounds, load them, unload them ... etc. Here is my code:
import time
import pygame
pygame.mixer.pre_init(44100, -16, 2, 2048)
pygame.mixer.init();
i = 0;
try:
while 1:
if not pygame.mixer.music.get_busy():
pygame.mixer.music.load('sounds/4min_440hz.mp3');
pygame.mixer.music.play(0);
print("Play sound \n");
elif i == 10:
pygame.poxer.music.stop();
i = 0;
time.sleep(0.5);
i += 1;
except KeyboardInterrupt: # exit
print('The end \n');
The sound plays fine, but as soon as I use the stop() method I get the following error:
Traceback (most recent call last):
File "soundTester.py", line 18, in <module>
*** Error in `python3': free(): invalid next size (normal): 0x00e70850 ***
Aborted
For the record I was testing this a few months back on a RPI3 and I had this error only after 3 or 4 stop() or so. Yesterday I tried on a RPI2 and I get it directly at the first stop(). I use the latest Raspbian build.
I did some research and it seems that this "free()" bug is not specific to pygame and happened in other situations with other libraries. Has anyone any idea on how to solve that?
Thanks in advance :)