- 浏览: 88260 次
- 性别:
- 来自: 昆明
A Note About kAudioSessionIncompatibleCategory Error on iOS 5 and 6
There is bug apparent on both iOS 5 and 6 (but not iOS 7) that manifests in apps that use the PlayAndRecord audio session category under certain multitasking conditions. The issue is triggered reliably via the following steps:
Open one app that uses both PlayAndRecord and background audio.
Open a second app that also uses PlayAndRecord and background audio.
Quit the first app, via the multitasking bar.
Open the first app again. The app will experience the error.
The error can also be caused by launching certain combinations of apps.
It results in a completely inoperable audio session, as well as a kAudioSessionIncompatibleCategory ('!cat') error when querying the kAudioSessionProperty_CurrentHardwareInputNumberChannels audio session property.
Once the error appears, the problem can only be resolved by quitting some or all running audio apps - unless the workaround described below is used.
See rdar://13022588 for further description.
We strongly recommend writing code to recognize this error state, and responds appropriately: First by implementing the workaround described below, and in the event of a failure in the workaround, informing the user accordingly, recommending that the user relaunches their apps.
Here's our proposed message to the user:
You’ve discovered a known issue with the iOS audio system that we have no control over.
Please relaunch all your music apps, making sure you launch the Audiobus app first.
You can frequently recover from this error by deactivating and reactivating the audio session:
AudioSessionSetActive(false);
AudioSessionSetActive(true);
This seems to resolve the issue when it arises sometimes, but at other times, it has no effect.
Nevertheless, we recommend making use of it to mitigate some of the effects of the bug, until Apple fix it.
The implementation of the workaround is simple: Early in your app's audio initialization, check the kAudioSessionProperty_CurrentHardwareInputNumberChannels property. If you get a kAudioSessionIncompatibleCategory error, restart the audio session:
UInt32 channels;
OSStatus result = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels);
if ( result == kAudioSessionIncompatibleCategory ) {
// Audio session error (rdar://13022588). Power-cycle audio session.
AudioSessionSetActive(false);
AudioSessionSetActive(true);
result = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels);
if ( result != noErr ) {
NSLog(@"Got error %d while querying input channels", result);
}
}
If there is no need for U to know the kAudioSessionProperty_CurrentHardwareInputNumberChannels value, you can delete the AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels); to avoid the problem.
There is bug apparent on both iOS 5 and 6 (but not iOS 7) that manifests in apps that use the PlayAndRecord audio session category under certain multitasking conditions. The issue is triggered reliably via the following steps:
Open one app that uses both PlayAndRecord and background audio.
Open a second app that also uses PlayAndRecord and background audio.
Quit the first app, via the multitasking bar.
Open the first app again. The app will experience the error.
The error can also be caused by launching certain combinations of apps.
It results in a completely inoperable audio session, as well as a kAudioSessionIncompatibleCategory ('!cat') error when querying the kAudioSessionProperty_CurrentHardwareInputNumberChannels audio session property.
Once the error appears, the problem can only be resolved by quitting some or all running audio apps - unless the workaround described below is used.
See rdar://13022588 for further description.
We strongly recommend writing code to recognize this error state, and responds appropriately: First by implementing the workaround described below, and in the event of a failure in the workaround, informing the user accordingly, recommending that the user relaunches their apps.
Here's our proposed message to the user:
You’ve discovered a known issue with the iOS audio system that we have no control over.
Please relaunch all your music apps, making sure you launch the Audiobus app first.
You can frequently recover from this error by deactivating and reactivating the audio session:
AudioSessionSetActive(false);
AudioSessionSetActive(true);
This seems to resolve the issue when it arises sometimes, but at other times, it has no effect.
Nevertheless, we recommend making use of it to mitigate some of the effects of the bug, until Apple fix it.
The implementation of the workaround is simple: Early in your app's audio initialization, check the kAudioSessionProperty_CurrentHardwareInputNumberChannels property. If you get a kAudioSessionIncompatibleCategory error, restart the audio session:
UInt32 channels;
OSStatus result = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels);
if ( result == kAudioSessionIncompatibleCategory ) {
// Audio session error (rdar://13022588). Power-cycle audio session.
AudioSessionSetActive(false);
AudioSessionSetActive(true);
result = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels);
if ( result != noErr ) {
NSLog(@"Got error %d while querying input channels", result);
}
}
If there is no need for U to know the kAudioSessionProperty_CurrentHardwareInputNumberChannels value, you can delete the AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels); to avoid the problem.
发表评论
-
Xcode 6 新建工程运行在 iOS 7 上下有黑边的问题
2014-11-02 10:01 2730原因:Xcode 6 默认新建的启动页面为 LaunchScr ... -
怎么创建 UITableViewCell 的 xib
2014-10-27 13:08 4681. 新建文件,选择 User Interface->V ... -
iOS 调试问题小结
2014-06-12 11:17 7141. XCode 提示 ”set a breakpoint i ... -
Could not launch " app name"
2013-12-19 11:11 627“could not launch app name” ... -
Why iOS 5.x doesn't work under Maverick
2013-12-19 09:52 649The iOS simulator does not dupl ... -
How to know whether a project uses ARC
2013-12-17 11:17 640There are 2 method to check whe ... -
把 iOS app logs 写入 documents 文件夹
2013-12-06 17:15 1000Now, in order to tell your app ... -
用 lipo 命令裁剪出需要的 architecture
2013-11-06 15:23 1388iOS 上的 framework 和 .a 库一般会同 ... -
写文件,真机和模拟器是不一样的
2013-10-17 22:30 484在真机上,只能往 Documents 和 tmp ... -
setValue:forUndefinedKey
2013-10-15 09:54 752使用 Storyboard 创建并管理 UI 时,在运行 ... -
创建 Empty Application时, storyboard 不显示的问题
2013-10-15 09:49 1146原因: 1. 创建 Empty Application 时没有 ... -
OC 和 C++ 混编
2013-10-08 15:45 748原文出处: http://blog.csdn.net ... -
Objective-C 中,@class & #import 的区别
2013-09-29 10:38 588Key points: "#Import&q ... -
Xcode如何打包ipa安装包
2013-09-05 11:41 1456http://jingyan.baidu.com/articl ... -
iOS 与 Armv6 Armv7 i386
2013-08-23 16:39 1169[size=medium]Armv6 binaries ... -
Difference: Category and Protocol
2013-07-14 16:45 593http://www.cnblogs.com/chijianq ... -
iOS 查看各个函数的执行顺序
2013-01-04 16:10 913- (BOOL)respondsToSelector:(SEL ... -
HOW TO ADD PHOTOS TO THE IPHONE SIMULATOR
2012-12-25 15:49 745Building an app that needs to a ... -
AutoReleasePool 学习笔记
2012-11-14 18:49 6791. In a reference-counted envir ...
相关推荐
2025最新电工技师考试题及答案.docx
项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载 技术组成 语言:java 开发环境:idea 数据库:MySql8.0 部署环境:Tomcat(建议用 7.x 或者 8.x 版本),maven 数据库工具:navicat
骨科康复医疗领域知识图谱建立及其分析.pdf
基于交易能量框架的多微电网最优能源管理:配网协同优化以降低运营成本, 关键词:Transactive energy,微电网 配网 参考文档:《Optimal Energy Management for Multi-Microgrid Under a Transactive Energy Framework With Distributionally Robust Optimization》2021一区半完美复现 仿真平台:MATLAB YALMIP GUROBI 主要内容:我们制定了一个基于交易能量(TE)框架的上游网络和网络中电网的能源调度的优化问题,以最小化运营成本。 市电网与上游网络之间的能源管理由配电系统运营商(DSO)操作,这不同于传统电力系统中的直接控制信号和固定定价机制。 ,Transactive energy; 微电网; 配网; 能源调度; 运营成本; 配电系统运营商(DSO); 交易能量框架; 优化问题; MATLAB YALMIP GUROBI。,Transactive Energy驱动的微电网配网能源调度优化策略研究
西门子1200 PLC与欧姆龙E5cc温控器双重控制通讯程序:远程触摸屏与本地温控器485通讯实现轮询式控制及温度监测,西门子1200与欧姆龙E5cc温控器 远程+本地双重控制通讯程序 功能:实现西门子1200 PLC对欧姆龙E5cc温控器进行485通讯控制,在触摸屏上设定温度,读取温度 ,也可以在温控器本体设定温度。 达到双重控制 程序采用轮询方式,有通讯故障后再恢复功能,也可以后续根据需要在此基础上扩充台数 器件:西门子1200 1214DC DC DC.昆仑通态TPC7062Ti ,西门子KTP700 Basic PN,欧姆龙E5cc温控器。 说明:是程序,带详细注释程序,触摸屏程序,PLC设置和温控器设置,接线说明书。 ,关键词:西门子1200;欧姆龙E5cc温控器;485通讯控制;远程+本地双重控制;轮询方式;通讯故障恢复;昆仑通态TPC7062Ti;西门子KTP700 Basic PN;详细注释程序;触摸屏程序;PLC设置;温控器设置;接线说明书。,西门子1200与欧姆龙E5cc温控器通讯控制程序:远程本地双重控制及详解
2025专业技术人员继续教育公需课题库(附含答案).pptx
2025医院手术室应急预案考核试题及答案.docx
2025数字化技术基础试题(含答案).docx
2025最新电信5G协优资格认证考试题库附含答案.docx
项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载 技术组成 语言:java 开发环境:idea 数据库:MySql8.0 部署环境:Tomcat(建议用 7.x 或者 8.x 版本),maven 数据库工具:navicat
COMSOL裂隙动水注浆扩散模拟:研究水泥-水玻璃与高聚物改性水泥浆液扩散规律及黏度时变特性影响分析,COMSOL裂隙动水注浆扩散数值模拟 针对动水注浆中常用的2种速凝浆液,水泥–水玻璃浆液与高聚物改性水泥浆液,考虑浆液黏度时变特性,应用有限元计算软件COMSOL Multiphysics建立动水条件下裂隙注浆扩散的数值模型,研究动水条件下裂隙注浆扩散规律并分析不同黏度时变特性、初始动水流速与注浆速率对注浆扩散过程的影响。 ,关键词:COMSOL Multiphysics;裂隙动水注浆;扩散数值模拟;速凝浆液;水泥-水玻璃浆液;高聚物改性水泥浆液;浆液黏度时变特性;有限元计算;注浆扩散规律;动水流速;注浆速率。,COMSOL模拟动水注浆扩散规律及影响因素研究
Simulink模型下的纯电动汽车、混合动力汽车及染料电池电动汽车的制动优先与能量管理功能解析,纯电动汽车Simulink模型;混合动力汽车Simulink模型;染料电池电动汽车Simulink模型。 纯电动汽车模型: 制动优先;充电禁止车辆驱动;驱动控制;再生能量回收;紧急停机功能; ,纯电动汽车模型:制动优先;充电禁止驱动;驱动控制;再生能量回收;紧急制动系统; 混合动力汽车模型:燃料类型切换;动力输出控制;能量回收策略;模式切换;效率优化; 染料电池电动汽车模型:染料电池性能;能量转换效率;充电过程模拟;电池管理系统;安全保护措施。,Simulink模型研究:多种能源驱动车辆动力系统控制优化
2025最新初级保育员理论知识考试题库及答案.doc
项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载 技术组成 语言:java 开发环境:idea 数据库:MySql8.0 部署环境:Tomcat(建议用 7.x 或者 8.x 版本),maven 数据库工具:navicat
项目已获导师指导并通过的高分毕业设计项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行!可以放心下载 技术组成 语言:java 开发环境:idea 数据库:MySql8.0 部署环境:Tomcat(建议用 7.x 或者 8.x 版本),maven 数据库工具:navicat
2025最新计算机网络技术考试题及答案.docx
西门子PLC与触摸屏的多功能检测设备编程案例:上下双工位四轴步进控制,双相机通讯与Modbus RTU交互,集成多重画面与配方功能,西门子1214PLC博图程序例程,版本V16及以上,加KTP700Basic PN触摸屏画面,双相机四轴多工位检测设备案例。 程序主要有: 上下双工位4轴脉冲控制步进电机; 与上位机双相机的TCP IP通讯; 有一台第三设备的modbus rtu通讯; 触摸屏包含多重画面,配方功能,密码 项目编程,现场调试电柜集成 ,核心关键词: 西门子1214PLC; 博图程序例程; 版本V16及以上; KTP700Basic PN触摸屏; 双相机四轴多工位检测设备; 上下双工位4轴脉冲控制步进电机; TCP IP通讯; 第三设备的modbus rtu通讯; 触摸屏多重画面; 配方功能; 密码保护; 项目编程; 现场调试电柜集成。,西门子PLC双相机四轴检测系统:博图程序例程与KTP700触摸屏集成应用
基于STM32bms与Battery Simulink的电池管理仿真系统及电池平衡控制策略模型,STM32bms动力电池管理系统仿真 Battery Simulink电池平衡控制策略模型 动力电池管理系统仿真 BMS + Battery Simulink 控制策略模型, 动力电池物理模型,需求说明文档。 BMS算法模型包含状态切模型、SOC估计模型(提供算法说明文档)、电池平衡模型、功率限制模型等,动力电池物理模型包含两种结构的电池模型。 通过上述模型可以实现动力电池系统的闭环仿真测试,亦可根据自身需求进行算法的更新并进行测试验证。 ,核心关键词: STM32bms; 动力电池管理系统仿真; Battery Simulink; 电池平衡控制策略模型; BMS算法模型; 状态切换模型; SOC估计模型; 电池平衡模型; 功率限制模型; 动力电池物理模型; 需求说明文档; 闭环仿真测试。,STM32bms系统下动力电池管理系统仿真与控制策略研究