• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

在模拟器/Xcode 录制音频时,Fresh SpeakHere 展示应用程序出错

用户头像
it1352
帮助1

问题说明

我无法使用 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 中打开全新下载并直接启动应用程序.我没有修改任何设置,也没有修改任何代码行.我也在谷歌和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 谷歌 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!

正确答案

#1

出现问题是因为在方法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);

在它的位置.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgbkaf
系列文章
更多 icon
同类精品
更多 icon
继续加载