在模拟器/Xcode 中录制音频时,Fresh SpeakHere 示例应用程序出错 [英] Fresh SpeakHere example app has error when recording audio in Simulator/Xcode

查看:42
本文介绍了在模拟器/Xcode 中录制音频时,Fresh SpeakHere 示例应用程序出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用 SpeakHere 来自苹果的示例应用程序.当我在 Xcode 中运行 Simulator 中的应用程序时,它正常启动,但是当我按下录制按钮时,出现错误线程 1:EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)":

I can't record audio using the SpeakHere example app from apple. When I run the app in Simulator from within Xcode, it starts up normally, but when I press the record button, the error "Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)" occurs:

在发生上述错误之前,有关应用启动时缺少根视图控制器的日志消息已经存在,并且可能与我的问题无关.

The log message about the missing root view controller at app startup is already there BEFORE the above error occurs and it is probably not connected to my problem.

我已经从链接的网站下载了 SpeakHere 示例项目(请参阅此问题的顶部),在 Xcode 中打开全新下载并直接启动应用程序.我没有修改任何设置,也没有修改任何代码行.我也在google和stackoverflow上搜索过这个问题,没有找到解决办法,虽然这个问题一定很普遍.

I have downloaded the SpeakHere example project from the linked website (see top of this question), opened the fresh download in Xcode and directly started the app. I did not modify any setting and not any line of code. I've also searched on google and stackoverflow for this problem and didn't find a solution, although this problem must be very general.

我使用 Xcode 4.5.2 (4G2008a) 和 2009 年末的 Mac OS X 10.8 MacBook Pro.

I use Xcode Version 4.5.2 (4G2008a) and a MacBook Pro from late 2009 with Mac OS X 10.8.

我也有一个朋友在他的电脑上试过这个,他也遇到了同样的问题.他有相同的操作系统,他的 XCode 版本也是 4.5.2.

I've also had a friend try this on his computer and he has the very same problem. He has the same OS and his XCode version is also 4.5.2.

我现在会尝试较旧的 Xcode 版本,但现在我不喜欢下载几 GB 的数据以在我的连接上进行试错法.

I would now try older Xcode versions, but right now I don't like to download a few gigabytes for a trial'n'error approach on my connection.

感谢任何帮助,包括诸如适用于我的 Xcode 版本......"之类的报告.谢谢!

Any help appreciated, including reports like "works for me with Xcode version ...". Thanks!

推荐答案

出现问题是因为在方法AQRecorder::StartRecord(CFStringRef inRecordFile)中,函数CFURLCreateWithString() 失败并返回一个指向 nil 的指针.这未被检测到,稍后代码在此 nil 指针上调用 CFRelease(),这会导致 EXC_BREAKPOINT.

The problem occurs because in the method AQRecorder::StartRecord(CFStringRef inRecordFile), the function CFURLCreateWithString() fails and returns a pointer to nil. This is not detected and later on the code calls CFRelease() on this nil pointer, which causes the EXC_BREAKPOINT.

CFURLCreateWithString() 方法的目的基本上是将一个 url 字符串作为输入并返回一个指向 CFURL 对象的指针作为输出.这里的问题是输入不是 url 字符串.相反,它只是本地文件系统上的一个路径,没有 file:/ 或类似前缀.因此,此方法失败.

The purpose of the method CFURLCreateWithString() basically is to take a url string as input and return a pointer to a CFURL object as output. The problem here is that the input is not a url string. Instead, it's simply a path on the local file system without file:/ or the like as prefix. For this reason, this method fails.

解决办法是去掉对方法CFURLCreateWithString()的无效调用,而是调用一个相关的方法,即CFURLCreateWithFileSystemPath(),它准备采取本地文件系统路径并将其转换为 CFURL:

The solution is to remove the not-working call to the method CFURLCreateWithString() and instead call a related method, namely CFURLCreateWithFileSystemPath(), which is prepared to take a local file system path and convert it to a CFURL:

在方法AQRecorder::StartRecord(CFStringRef inRecordFile)中,替换或注释掉该行

In the method AQRecorder::StartRecord(CFStringRef inRecordFile), replace or comment out the line

url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL);

并插入

url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)recordFile, kCFURLPOSIXPathStyle, false);

在它的位置.

这篇关于在模拟器/Xcode 中录制音频时,Fresh SpeakHere 示例应用程序出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆