Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

ios - AVAudioPlayer throws breakpoint in debug mode

Every time I load the app it stops as if I had set a breakpoint on this line:

self.audioPlayer = 
 [[[AVAudioPlayer alloc] initWithData:[dataPersister loadData:self.fileName] 
                                error:&outError] autorelease];

There's no breakpoint above or any place near this line. It only happens when I run the app in debug mode and nothing crashes after the breakpoint. The app works as nothing happened when I click "Continue program execution".

This is the loadData method, which is called with initWithData:

-(NSData*)loadData:(NSString*)fileName
{
    NSString *dataPath = [self.path stringByAppendingPathComponent:fileName];
    dataPath = [dataPath stringByStandardizingPath];
    NSData *data = [[[NSData alloc] initWithContentsOfFile:dataPath]autorelease ];
    return data;
}

The loadData function seems to be working fine. The requested mp3 file is loaded and played without any problems after the breakpoint.

Do you have any idea what I'm doing wrong?

EDIT: I ran a backtrace when it stops at the breakpoint. This was the output:

(lldb) bt
* thread #1: tid = 0x1c03, 0x30df1724 libc++abi.dylib`__cxa_throw, stop reason = breakpoint 1.2
    frame #0: 0x30df1724 libc++abi.dylib`__cxa_throw
    frame #1: 0x36403a24 AudioToolbox`ID3ParserHandle::ID3ParserHandle(void*, long (*)(void*, unsigned long, unsigned long, unsigned long, void**, unsigned long*)) + 452
    frame #2: 0x36403b0e AudioToolbox`ID3ParserOpen + 142
    frame #3: 0x3635bd16 AudioToolbox`MPEGAudioFile::ParseID3Tags() + 58
    frame #4: 0x3635b9aa AudioToolbox`MPEGAudioFile::ParseAudioFile() + 26
    frame #5: 0x3631723e AudioToolbox`AudioFileObject::DoOpenWithCallbacks(void*, long (*)(void*, long long, unsigned long, void*, unsigned long*), long (*)(void*, long long, unsigned long, void const*, unsigned long*), long long (*)(void*), long (*)(void*, long long)) + 166
    frame #6: 0x36316480 AudioToolbox`AudioFileOpenWithCallbacks + 612
    frame #7: 0x31f4c1ec AVFoundation`-[AVAudioPlayer initWithData:error:] + 120

"SOLUTION": It turns out, if I disable exception breakpoint for all exceptions and only use breakpoint for Objective-C exceptions the problem disappears. But it doesn't solve the problem that the allocation of AVAudioPlayer throws a C++ exception.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add your exception breakpoint and edit the exception type from "All" to "Objective-C exceptions"

Some classes in AudioToolbox throw regular C++ exceptions. You can filter them off this way.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...