iPhone 上的音频队列服务仅播放第一个排队的缓冲区?
我整夜没睡,试图弄清楚这个问题。我的代码与 Apple 的示例基本相同此处。但是,设备仅播放队列中放置的第一个缓冲区(应用程序启动时我听到第一个缓冲区的内容)。之后,设备将不再发出任何声音。尽管 AQS 继续触发我的 AudioQueueOutputCallback
函数,但播放仍在运行。此外,每次调用 AQS 都会返回 0,因此没有任何失败。
现在,只要从回调函数中调用 AudioQueueEnqueueBuffer
,我就可以获得后续缓冲区的播放。这不起作用,因为我只能从 AudioFileStream_PacketsProc
回调中填充缓冲区并将其排入队列,因为数据电影从套接字传输到 AudioFileStreamParseBytes
中。
还有其他人有这个问题吗?对我来说,这似乎是 AQS 中的一个错误...
谢谢, 安德鲁
I've been up all night trying to figure this one out. My code is basically the same as Apple's example here. However, the device plays only the FIRST buffer placed in the queue (I hear the contents of the first buffer when the app starts). After that, no sound will come from the device at all. The playback is still running though as AQS continues to fire my AudioQueueOutputCallback
function. Additionally, every call to AQS returns 0 so nothing is failing.
Now, I can get subsequent buffers to play as long as I call AudioQueueEnqueueBuffer
from WITHIN my callback function. This won't work as I can only fill and enqueue the buffers from within my AudioFileStream_PacketsProc
callback as the data cines from the socket and into AudioFileStreamParseBytes
.
Anyone else have this problem? Seems like a bug in AQS to me...
Thanks,
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
弄清楚以防其他人遇到这个问题...
我没有意识到 AQ 总是及时前进。由于我使用的是来自 UDP 数据流的音频数据,因此我会因为丢包而慢慢落后于 AQ。
我一直无法弄清楚如何告诉 AQ“立即”播放缓冲区。我的解决方法是当我检测到丢弃的数据包时重置 AQ。这并不理想,但目前有效。
安德鲁
Figured it out in case anyone else has this problem...
I didn't realize the AQ always moves forward in time. Since I was using audio data from a UDP data stream, I would slowly fall behind the AQ because of lost packets.
I haven't been able to figure out how to tell the AQ to play a buffer "right-now". My workaround is to just reset the AQ when I detect a dropped packet. This isn't ideal but works for now.
Andrew