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

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

问题描述

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

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

我已经从链接的网站下载了SpeakHere示例项目(请参阅此问题的顶部),在Xcode中打开了全新的下载文件,并直接启动了该应用程序.我没有修改任何设置,也没有任何代码行.我也在google和stackoverflow上搜索了此问题,但没有找到解决方案,尽管此问题必须非常笼统.

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

我也有一个朋友在他的计算机上尝试此操作,他也遇到了同样的问题.他具有相同的操作系统,并且他的XCode版本也为4.5.2.

我现在将尝试使用较旧的Xcode版本,但是现在我不希望下载几GB的数据来尝试在连接时尝试"n'error"方法.

任何帮助表示赞赏,包括诸如为Xcode版本为我工作..."之类的报告.谢谢!

解决方案

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

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

解决方案是删除对方法CFURLCreateWithString()的无效调用,而是调用相关方法CFURLCreateWithFileSystemPath(),该方法准备采用本地文件系统路径并将其转换为CFURL:

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

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

然后插入

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

在其位置.

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.

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.

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

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.

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.

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

解决方案

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.

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.

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:

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

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

and insert

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

at its place.

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

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