12

我在 4.3.2、5.0 和 5.1 模拟器中运行 iOS 程序,并且在 AudioToolbox 中遇到了一个奇怪的内部异常。我在 Xcode(Xcode 4.3.1,在 10.7.3 上运行)中为所有异常设置了一个断点,并且调试器在调用期间中断AudioServicesCreateSystemSoundID()

SystemSoundID soundID;
OSStatus errorCode = AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
                  // ^ boom. ^

回溯:

(lldb) bt
* thread #1: tid = 0x1f03, 0x9000e230 libc++abi.dylib`__cxa_throw, stop reason = breakpoint 1.2
frame #0: 0x9000e230 libc++abi.dylib`__cxa_throw
frame #1: 0x00144193 AudioToolbox`ID3ParserHandle::ID3ParserHandle(void*, long (*)(void*, unsigned long, unsigned long, unsigned long, void**, unsigned long*)) + 259
frame #2: 0x001442de AudioToolbox`ID3ParserOpen + 62
frame #3: 0x0006c0e7 AudioToolbox`MPEGAudioFile::ParseID3Tags() + 87
frame #4: 0x0006c2ba AudioToolbox`MPEGAudioFile::ParseAudioFile() + 26
frame #5: 0x00015153 AudioToolbox`AudioFileOpenWithCallbacks + 371
frame #6: 0x00027020 AudioToolbox`_ZL15VerifyAndMapURLPK7__CFURLRx + 448
frame #7: 0x00026d85 AudioToolbox`_ZL18ActionDataToServerPK7__CFURLm + 933
frame #8: 0x000da26b AudioToolbox`AudioServicesCreateSystemSoundID + 235
frame #9: 0x00005be1 app`-[SoundsViewController playSoundForPath:] + 257 at SoundsViewController.m:161
frame #10: 0x00005a99 app`-[SoundsViewController tableView:didSelectRowAtIndexPath:] + 777 at SoundsViewController.m:129
frame #11: 0x0029db68 UIKit`-[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
frame #12: 0x00293b05 UIKit`-[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
frame #13: 0x009ad79e Foundation`__NSFireDelayedPerform + 441
frame #14: 0x00fb58c3 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
frame #15: 0x00fb6e74 CoreFoundation`__CFRunLoopDoTimer + 1220
frame #16: 0x00f132c9 CoreFoundation`__CFRunLoopRun + 1817
frame #17: 0x00f12840 CoreFoundation`CFRunLoopRunSpecific + 208
frame #18: 0x00f12761 CoreFoundation`CFRunLoopRunInMode + 97
frame #19: 0x01f6b1c4 GraphicsServices`GSEventRunModal + 217
frame #20: 0x01f6b289 GraphicsServices`GSEventRun + 115
frame #21: 0x00234c93 UIKit`UIApplicationMain + 1160
frame #22: 0x00002c45 app`main + 181 at main.m:14

但是里面的音频文件soundID创建成功,AudioServicesCreateSystemSoundID返回的OSStatus错误码为0。

这发生在我安装的所有三个 iOS 模拟器版本中,以及运行 5.1 的 iPhone 上。

这看起来与AVAudioPlayer 在调试模式下抛出断点相同的一般回溯,尽管我的是更直接调用 AudioToolbox 的结果。

我想将此提交给 Apple,因为它是 AudioToolbox 中的一个错误(框架不应该使用流控制异常,每个 bbum 和其他人),但在我这样做之前,我想知道我可以收集哪些其他信息给他们,如果有任何方法可以避免这种抛出(也许通过调整这个 mp3 中的 ID3 标签?)

4

2 回答 2

6

我们在同一个地方遇到了一个异常,结果发现它发生的 mp3 文件没有有效的 ID3 标签,通过Tagr等应用程序运行它们修复了它们。

于 2013-02-27T21:53:28.453 回答
3

C++ 库可能出于各种原因在内部抛出和捕获异常,例如缓冲区结束或文件结束。这是否是对异常的适当使用、良好的编码风格或软件工程实践是值得商榷的。只要异常不会使其未被捕获到您的代码中,您就不必担心它。

您说例程成功返回并获得了所需的输出,因此没有任何问题(即它不是错误)。

于 2012-07-02T18:18:24.947 回答