简体   繁体   English

iOS AudioQueue播放AAC数据始终延迟2-3秒

[英]iOS AudioQueue playing AAC data always delay for 2-3 seconds

Recently I was using AudioQueue to play network AAC data. 最近,我正在使用AudioQueue播放网络AAC数据。 My plan is that once a AAC data is received, audioqueue enqueue this buffer and play immediately. 我的计划是,一旦收到AAC数据,音频队列就会将该缓冲区排入队列并立即播放。

When I start audioQueue, I use AudioQueueStart(audioQueue, NULL) to start audioQueue as soon as possible. 启动audioQueue时,我使用AudioQueueStart(audioQueue, NULL)尽快启动audioQueue。

However, when I print log, I notice that the AAC buffer was enqueued by AudioQueueEnqueueBuffer(audioQueue, buffer, 0, NULL) immediately but the sound played after enqueuing buffer which delayed for around 2-3 seconds. 但是,当我打印日志时,我注意到AAC缓冲区立即被AudioQueueEnqueueBuffer(audioQueue, buffer, 0, NULL)排队,但是排队缓冲区后播放的声音延迟了大约2-3秒。 It means I received and enqueued the data at beginning but the first sound started 2-3 seconds later. 这意味着我一开始就接收并排队了数据,但是第一个声音在2-3秒后开始。

I wonder if it is because that audioqueue service decode AAC to PCM itself so the sounds delayed. 我想知道是否是因为音频队列服务将AAC解码为PCM本身,所以声音延迟了。 If so, should I decode AAC myself and use Audio Unit instead? 如果是这样,我应该自己解码AAC并改用音频单元吗?

I've been confused for a while and wish anyone can light me up! 我已经困惑了一阵子了,希望有人能照亮我!

Finally I found the reason. 终于我找到了原因。 When the AAC data is late, I pause the audioQueue and start again when the data come. 当AAC数据迟到时,我暂停audioQueue并在数据到来时重新开始。 the PAUSE operation lead to the delay of playback. 暂停操作会导致播放延迟。

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

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