Comment 5 for bug 290691

Revision history for this message
marmuta (marmuta) wrote :

I agree that it shouldn't eat cpu when not explicitely asked to play. On the other hand, I could imagine this being a design choice for (game) performance reasons. The issue is probably low latency, no need to restart the sound hardware for each bullet.

I had a closer look at the pygame and sdl_mixer. The call sequence goes
pygame.mixer.init() -> Mix_OpenAudio -> SDL_OpenAudio and SDL_PauseAudio(0).
The stream will always start playing, there is no way around it and it has been like this throughout the history of pygame and sdl_mixer.

Here is the latest and very first version of pygame. see autoinit() in /src/mixer.c:
http://www.pygame.org/ftp/pygame-1.8.1release.tar.gz
http://www.pygame.org/ftp/old/pygame-0.1a.tar.gz

And the same for sdl_mixer, see Mix_OpenAudio():
http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL_mixer/mixer.c?view=markup
http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL_mixer/mixer.c?revision=2&view=markup

So, there has to be something else going on. Maybe it's a hardware thing. I believe some sound cards have hardware mixers and skip the software resampling. Could be my crappy onboard sound to blame. Or has Intrepids sound stack slowed down?

Whatever the reason for the cpu usage, there shouldn't be a silent audio stream around anyway.
Maybe mnemosyne really should take care of this. It would be super If that happened in 2.0 with phonon, but I'm also willing to contribute a patch for the current version.
Will there be a 2.0 release soon?