Hey,
Based on the example given in the "Mobile Python" book (simply amazing book btw), i've managed to get my application to open and play a .wav file until it finishes, by using the sound callback function. What I'm trying to do now is initiate the act of playing the sound inside a NEW thread, so my main thread can continue its execution without being held by the Ao_lock(). This is what I've done so far, I try opening the audio file and then pass the open handler to a new thread, and I've included the sound_callback function as a nested function inside my threaded one, so that it has access to the sound_lock object (no race condition, i hope!). But, it doesn't seem to get past the "here in the beginning" point... does anyone have an idea what might be going wrong?
Thnx in advance!!
Code:def sound_thread(sound): sound_lock = e32.Ao_lock() def sound_callback(prev_state, current_state, err): print "here in the middle" if current_state == audio.EOpen: sound_lock.signal() print "here at the beginning" sound.play(callback = sound_callback) sound_lock.wait() sound.close() print "here at the end" def playsound(file_name): sound_file = SOUNDS_PATH + file_name + ".wav" sound = audio.Sound.open(sound_file) thread.start_new_thread(sound_thread, (sound, ))

Reply With Quote



