确定缓冲区何时已播放,无需轮询 OpenAL 中的源
这可能吗?如果我设法在每次处理缓冲区时调用一个函数,那就太酷了。除了轮询来源之外的任何其他想法都受到欢迎:D
Is this even possible? Would be extra cool if somehow I manage to have a function called every time a buffer has been processed. Any other ideas besides polling the source it's welcomed :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您知道每个缓冲区中有多少样本,并且知道源播放的采样率。这应该可以让您很好地了解源何时完成缓冲区的处理。
如果您感觉非常勇敢,您可以将其侵入 OpenAL-soft 源代码。从代码的外观来看,您可以将更改放入文件最末尾的
mixer.c
中,即靠近MixSource()
函数末尾的位置。当然,请记住 OpenAL-soft 是 lGPL;因此您需要发布/提供对库本身所做的任何更改。
如果您坚持使用预包含的库,那么您没有太多选择。 OpenAL 拒绝回调函数的想法。
You know how many samples are in each buffer and you know the sample rate that the source is playing at. That should give you a pretty good idea of when the source will finish processing a buffer.
If you're feeling very intrepid, you could hack this into the OpenAL-soft source. By the looks of the code, you would put the change into
mixer.c
at the very end of the file, somewhere near the end of theMixSource()
function.Remembering, of course, that OpenAL-soft is lGPL; so you'd need to release/make available any changes that you made to the library itself.
If you're stuck using pre-included libraries, then you don't have many options. OpenAL rejects the idea of callback functions.