pySonic + pyOgre crashes ...


19-05-2006 22:59:27

For anyone using pySonic and pyOgre (Jason and his Golem engine, for example), have you had any problems with pySonic crashes caused by StreamCallbacks? I have written a simple pure python (non-threaded) sound manager as part of my pyOgre-based game engine but am suffering from python crashes at the end of each sample. I thought it was my code but have since pared it back to the simplest of pySonic examples.

import pySonic
import time

# define a callback function
flag = False
def stream_done(source):
global flag
flag = True
print 'stream ended'

# create world and source; prepare audio
w = pySonic.World()
src = pySonic.Source()
src.Sound = pySonic.FileStream('test.wav')

# comment this out to stop crashes ... but also no notification

# play until callback
while not flag:

As written, this crashes python after the StreamCallback prints 'stream ended'. If I uncomment the sleep(0.1) statement, crashes disappear (or become vanishingly infrequent). With the small time.sleep(0.001) uncommented, I get crashes about 25% of the time. Commenting out the callback fixes the problem at the cost of having to poll sounds to see if they are still active or not.

As I said, the above is a contrived example, but its essentially what happens when running the pyogre event loop.

System configuration is: python 2.4, pySonic 0.8, FMOD 3.75, WinXP, 3GHz dual-core intel P4 machine.

Any advice is much appreciated ...



06-06-2006 18:33:16

We used PySonic for A Violent World (check the projects thread), but I never noticed any crashes directly related to it. However, the game does crash occasionally, but it could just as well be buggy game code that does it, so I can't really blame it on PySonic (sadly ;)).