[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame.init before pygame.mixer.init?



Hi Clare,

comments below

On 10/10/07, Clare Richardson <clare@xxxxxxxxxxxxx> wrote:
> I writing a program to simply play one sound (see below for the code),
> and came across some interesting behavior.  If I call pygame.init()
> before pygame.mixer.init(), I don't hear any sound playing.  However if
> I call pygame.init *after* pygame.mixer.init (as below), the sound will
> play.
>
> Is this a known behavior?  What's causing the problem?  I understand
> that I don't need pygame.init to just play a sound, but I don't think it
> should matter if I call it.
>
The behavior you describe may very well be a bug, and is something
that should probably be fixed - and if some SDL and/or pygame source
programmer repro's it with your sample code, it probably will get
fixed.


However, I don't think calling pygame.mixer.init is ever really a good
thing, and you probably shouldn't bother. There is another function,
pygame.mixer.pre_init, which takes the same args as pygame.mixer.init,
and is specifically designed to be called before pygame.init

Basically if you are calling mixer.init without args... well I don't
think there is any benefit to doing so, and so you might be happier if
you don't

If you are calling it with args, well try calling
pygame.mixer.pre_init instead, just before your pygame.init call,
cause it will make sure your mixer gets init once only, the right way
for your given args you want to use.