tags:

views:

81

answers:

1

I'm looking at PyOpenAL for some sound needs with Python (obviously). Documentation is sparse (consisting of a demo script, which doesn't work unmodified) but as far as I can tell, there are two layers. Direct wrapping of OpenAL calls and a lightweight 'pythonic' wrapper - it is the latter I'm concerned with. Specifically, how do you clean up correctly? If we take a small example:

import time

import pyopenal

pyopenal.init(None)

l = pyopenal.Listener(22050)

b = pyopenal.WaveBuffer("somefile.wav")
s = pyopenal.Source()
s.buffer = b
s.looping = False

s.play()

while s.get_state() == pyopenal.AL_PLAYING:
    time.sleep(1)

pyopenal.quit()

As it is, a message is printed on to the terminal along the lines of "one source not deleted, one buffer not deleted". But I am assuming the we can't use the native OpenAL calls with these objects, so how do I clean up correctly?

EDIT:

I eventually just ditched pyopenal and wrote a small ctypes wrapper over OpenAL and alure (pyopenal exposes the straight OpenAL functions, but I kept getting SIGFPE). Still curious as to what I was supposed to do here.

+1  A: 
#relese reference to l b and s
del l
del b
del s 
#now the WaveBuffer and Source should be destroyed, so we could:
pyopenal.quit()

Probably de destructor of pyopenal calls quit() before exit so you dont need to call it yourself.

lionbest
Makes sense. I don't have PyOpenAL installed ATM, so I'll take your word.
Bernard