简体   繁体   English

音频队列:记录缓冲区的时间戳

[英]Audio Queue: Timestamps for recorded buffers

I am trying to grab times out of recorded buffers in my AudioInputCallback function for a recording queue. 我试图从我的AudioInputCallback函数中为记录队列中的记录缓冲区中抓取时间。 Unfortunately the timestamps I'm seeing aren't as expected. 不幸的是,我看到的时间戳与预期不符。 Here's an example (using AudioTimeStamp.mHostTime ): 这是一个示例(使用AudioTimeStamp.mHostTime ):

2010-01-21 14:03:35.252 [61694:207] 1288747268011206    1288747396166138    -128154932
2010-01-21 14:03:35.344 [61694:207] 1288747360891024    1288747396166138    -35275114
2010-01-21 14:03:35.437 [61694:207] 1288747453770843    1288747396166138    57604705
2010-01-21 14:03:35.530 [61694:207] 1288747546652078    1288747396166138    150485940

The first timestamp is buffer time, the second is reference time (time at which the button was pressed, I am using AudioQueueDeviceGetCurrentTime ) and third is the delta between the two. 第一个时间戳是缓冲时间,第二个是参考时间(按下按钮的时间,我正在使用AudioQueueDeviceGetCurrentTime ),第三个是两者之间的差异。 As expected, the buffers slightly lag "real time" and catch up after a couple buffer callbacks have been run. 正如预期的那样,在运行了两个缓冲区回调之后,缓冲区稍微滞后于“实时”,并赶上了。

Now when closing and reopening this queue, the story is much different: 现在,当关闭并重​​新打开此队列时,情况就大不相同了:

2010-01-21 14:03:46.769 [61694:207] 1288755719477798    1288758853485434    -3134007636
2010-01-21 14:03:46.862 [61694:207] 1288755812365464    1288758853485434    -3041119970
2010-01-21 14:03:46.955 [61694:207] 1288755905305200    1288758853485434    -2948180234

As you can see, the timestamps (ns I suppose?) are way different the second time around. 如您所见,第二次时间戳记(我想是吗?)截然不同。 They don't catch up to real time for several seconds. 他们几秒钟都无法赶上实时。 This behavior is not at all reproducible -- the timestamps are sometimes right and sometimes wrong. 这种行为根本无法重现-时间戳有时是正确的,有时是错误的。 They are always wrong the first time I open the queue however. 但是,当我第一次打开队列时,它们总是错误的。

因此,再次喘口气并在SO上发布已解决了问题;)在队列停止/暂停时,您不应获取队列的当前时间戳记:^ P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM