我在 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 throws breakpoint in debug mode 相同的一般回溯,尽管我的是更直接调用 AudioToolbox 的结果。
我想向 Apple 提交此文件,因为它是 AudioToolbox 中的一个错误(框架不应该使用异常进行流量控制,per bbum 和其他人),但在我这样做之前,我想知道我可以收集哪些其他信息来给他们,如果有任何方法可以避免这种抛出(也许通过调整这个 mp3 中的 ID3 标签?)
最佳答案
我们在同一个地方遇到了异常,结果是发生异常的 mp3 文件没有有效的 ID3 标签,通过 Tagr 等应用程序运行它们修复它们。
关于objective-c - 为什么 AudioServicesCreateSystemSoundID 内部抛出异常,却返回 0 作为错误码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9811512/
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
它不等于主线程的binding,这个toplevel作用域是什么?此作用域与主线程中的binding有何不同?>ruby-e'putsTOPLEVEL_BINDING===binding'false 最佳答案 事实是,TOPLEVEL_BINDING始终引用Binding的预定义全局实例,而Kernel#binding创建的新实例>Binding每次封装当前执行上下文。在顶层,它们都包含相同的绑定(bind),但它们不是同一个对象,您无法使用==或===测试它们的绑定(bind)相等性。putsTOPLEVEL_BINDINGput
我可以得到Infinity和NaNn=9.0/0#=>Infinityn.class#=>Floatm=0/0.0#=>NaNm.class#=>Float但是当我想直接访问Infinity或NaN时:Infinity#=>uninitializedconstantInfinity(NameError)NaN#=>uninitializedconstantNaN(NameError)什么是Infinity和NaN?它们是对象、关键字还是其他东西? 最佳答案 您看到打印为Infinity和NaN的只是Float类的两个特殊实例的字符串
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象