如何在 openal 中获取播放源的当前位置?我想我的意思是,在经过你的缓冲区、openal 缓冲区、硬件缓冲区等之后,音频当前在硬件上播放的位置。
我已经简要查看了 api,但我不太确定 AL_SAMPLE_OFFSET/AL_BYTE_OFFSET/AL_SEC_OFFSET 代表什么。如果我正在播放流媒体源,我似乎没有得到不断增加的数字,似乎我在当前播放缓冲区中获得了一个位置? (或所有缓冲区?)
例如,在玩游戏时,我循环并运行以下代码:
alGetSourcef( sources[0], AL_SAMPLE_OFFSET, &secoffset );
printf(" - %f samples\n", secoffset);
并得到
- 0.000000 samples
- 8192.000000 samples
- 9216.000000 samples
- 5632.000000 samples
似乎并没有增加。
这是在带有最新 xcode 4.3 的 macos 10.7 上,但我假设它在其他平台上应该类似。
更新:
我尝试增加缓冲区大小,它实际上看起来只是当前播放缓冲区中的当前位置:
- 0.000000 bytes
- 18432.000000 bytes
- 20480.000000 bytes
- 36864.000000 bytes
- 36864.000000 bytes
- 55296.000000 bytes
- 55296.000000 bytes
- 73728.000000 bytes
refilling buffer 2408
re-queued buffer 2408
- 16384.000000 bytes
- 34816.000000 bytes
- 34816.000000 bytes
- 51200.000000 bytes
- 51200.000000 bytes
- 69632.000000 bytes
refilling buffer 2409
re-queued buffer 2409
鉴于此,是否有一种不错的方法可以在开放式游戏通过多个不同的缓冲区进行播放时进行跟踪?
最佳答案
这些偏移量是从排队缓冲区的开头开始的。您需要手动计算已未排队的缓冲区的大小并添加到该数字中。
在这里,如果您阅读 documentation ,第 40 页上说:
The position is relative to the beginning of all the queued buffers for the source, and any queued buffers traversed by a set call will be marked as processed.
关于audio - openal:获取源的当前播放位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10160401/