iPhone CoreAudio 停止时挂起

发布于 2024-09-06 05:24:18 字数 772 浏览 3 评论 0原文

我有一个 iPhone 应用程序可以录制音频,然后通过网络进行广播。为了响应来自远端的“停止”,它会排队通知以停止录制。唉,当它到达 AudioQueueStop 调用时,应用程序只是挂起(即 Stop 永远不会退出)。感谢通知,所有 AudioQueue 操作都发生在同一线程上。

有谁知道这里发生了什么事吗?

编辑:我已经在处理记录器的 UI 线程中设置了一个侦听器。

然后,从我的网络线程中,我使用“postNotificationName”,相信它会向 UI 线程发布一条消息,并且所有内容都会从该线程运行。事实似乎并非如此。当我断点 postNotificationName 调用的函数时,似乎调用是在网络线程上进行的,而不是在 UI 线程上进行的。

我认为这是我的错误。有人知道如何通过通知 UIThread 来处理它来使其工作吗?

Edit2:好的,我已经重写它以使用performSelectorOnMainThread。它仍然崩溃。

从好的方面来说,我刚刚学会了如何从 XCode 中获取更多信息,这样我就可以看到调用堆栈的情况:

semaphore_timedwait_signal_trap
semaphore_timedwait_signal
_pthread_cond_wait
pthread_cond_timedwait_relative_np
CAGuard::等待
ClientAudioQueue::ServicePendingCallbacks
音频队列停止
[etc]

有人知道它为什么挂起吗?

I have an iPhone app that is recording audio and then broadcasting it across the network. In response to a "stop" from the far end it queues a notification to stop the recording. Alas when it gets to the AudioQueueStop call the application just hangs (ie Stop never exits). Thanks to the notification all AudioQueue manipulation is happening on the same thread.

Has anyone got any idea whats going on here?

Edit: I have set up a listener in the UI thread that handles the recorder.

Then from my network thread I use a "postNotificationName" beliving that it was post a message to the UI thread and everything would run from that thread. This does not appear to be the case. When I break point the function that is called by the postNotificationName it appears that the call is being made on the networking thread and NOT on the UI Thread.

I assume this is my error. Anyone know how to make it work by notifying the UIThread to handle it?

Edit2: OK I've re-written it to use performSelectorOnMainThread. And it still crashes.

On the plus side I just learnt how to get a lot more info out of XCode so I can see the call stack goes:

semaphore_timedwait_signal_trap
semaphore_timedwait_signal
_pthread_cond_wait
pthread_cond_timedwait_relative_np
CAGuard::WaitFor
ClientAudioQueue::ServicePendingCallbacks
AudioQueueStop
[etc]

Anyone got any ideas why it hangs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深爱成瘾 2024-09-13 05:24:18

如何调用 AudioQueueStop ?该函数支持两种模式:同步和异步。

首选方法是使用异步停止,因为函数将立即返回,而剩余的缓冲区将被播放/记录。

如果您想要同步并且遇到挂起,那么可能在某处存在死锁或竞争条件。您是否尝试过在调试器下暂停应用程序并检查线程的堆栈帧以查看问题出在哪里?

How do you call AudioQueueStop ? The function supports two modes: synchronous and asynchronous.

The preferred way is to use the asynchronous stopping as the function will return immediately, while the remaining buffers will be played/recorded.

If you want to go synchronous and you get a hang, then maybe there is a dead-lock or a race condition somewhere. Have you tried to pause the application under the debugger and check the threads' stack-frames to see where the problem is ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文