使用 PyOpenAL 时正确的清理方法是什么?
我正在寻找 PyOpenAL 来满足 Python 的一些声音需求(显然)。 文档很少(由演示脚本组成,未经修改就无法工作),但据我所知,有两层。 直接包装 OpenAL 调用和轻量级“pythonic”包装器 - 我关心的是后者。 具体来说,如何正确清理呢? 如果我们举一个小例子:
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()
事实上,一条消息被打印到终端上,内容是“一个源未删除,一个缓冲区未删除”。 但我假设我们无法对这些对象使用本机 OpenAL 调用,那么如何正确清理呢?
编辑:
我最终放弃了 pyopenal,并在 OpenAL 和 alure 上编写了一个小的 ctypes 包装器(pyopenal 公开了直接的 OpenAL 函数,但我不断收到 SIGFPE)。 仍然好奇我应该在这里做什么。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pyopenal 的析构函数可能在退出之前调用
quit()
,因此您不需要自己调用它。Probably de destructor of pyopenal calls
quit()
before exit so you dont need to call it yourself.