Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fresh SpeakHere example app has error when recording audio in Simulator/Xcode

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:screenshot after problem occurred

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!

like image 995
Daniel S. Avatar asked Dec 18 '25 07:12

Daniel S.


1 Answers

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.

like image 131
Daniel S. Avatar answered Dec 19 '25 22:12

Daniel S.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!