- 浏览: 87563 次
- 性别:
- 来自: 昆明
kAudioSessionIncompatibleCategory
- 博客分类:
- iOS
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 2715原因:Xcode 6 默认新建的启动页面为 LaunchScr ... -
怎么创建 UITableViewCell 的 xib
2014-10-27 13:08 4581. 新建文件,选择 User Interface->V ... -
iOS 调试问题小结
2014-06-12 11:17 6961. XCode 提示 ”set a breakpoint i ... -
Could not launch " app name"
2013-12-19 11:11 616“could not launch app name” ... -
Why iOS 5.x doesn't work under Maverick
2013-12-19 09:52 628The iOS simulator does not dupl ... -
How to know whether a project uses ARC
2013-12-17 11:17 626There are 2 method to check whe ... -
把 iOS app logs 写入 documents 文件夹
2013-12-06 17:15 988Now, in order to tell your app ... -
用 lipo 命令裁剪出需要的 architecture
2013-11-06 15:23 1372iOS 上的 framework 和 .a 库一般会同 ... -
写文件,真机和模拟器是不一样的
2013-10-17 22:30 477在真机上,只能往 Documents 和 tmp ... -
setValue:forUndefinedKey
2013-10-15 09:54 730使用 Storyboard 创建并管理 UI 时,在运行 ... -
创建 Empty Application时, storyboard 不显示的问题
2013-10-15 09:49 1130原因: 1. 创建 Empty Application 时没有 ... -
OC 和 C++ 混编
2013-10-08 15:45 737原文出处: http://blog.csdn.net ... -
Objective-C 中,@class & #import 的区别
2013-09-29 10:38 578Key points: "#Import&q ... -
Xcode如何打包ipa安装包
2013-09-05 11:41 1439http://jingyan.baidu.com/articl ... -
iOS 与 Armv6 Armv7 i386
2013-08-23 16:39 1156[size=medium]Armv6 binaries ... -
Difference: Category and Protocol
2013-07-14 16:45 579http://www.cnblogs.com/chijianq ... -
iOS 查看各个函数的执行顺序
2013-01-04 16:10 892- (BOOL)respondsToSelector:(SEL ... -
HOW TO ADD PHOTOS TO THE IPHONE SIMULATOR
2012-12-25 15:49 734Building an app that needs to a ... -
AutoReleasePool 学习笔记
2012-11-14 18:49 6681. In a reference-counted envir ...
相关推荐
内容概要:本文提供了详细的MongoDB分片集群的搭建指导,涵盖了从环境准备、配置文件编写、副本集的建立、主节点的选择、配置服务器和数据分片服务器的配置到最后的路由节点的搭建与操作整个流程,以及对数据库的哈希与范围两种分片策略的应用介绍和具体命令执行。 适合人群:熟悉NoSQL数据库概念并对MongoDB有一定了解的技术人员,尤其是在大型数据管理和分布式数据库架构设计中有需求的开发者。 使用场景及目标:帮助技术人员掌握构建高效能、高可用性的MongoDB分片集群的方法,适用于处理大规模、实时性强的数据存储与读取场景。 其他说明:文中通过实例演示了每个步骤的具体操作方法,便于跟随文档实操,同时也介绍了可能遇到的问题及其解决方案,如在没有正确配置的情况下试图写入数据时出现错误等情况的处理。
CPPC++_嵌入式硬件的物联网解决方案blinker库与Arduino ESP8266 ESP32一起工作
CPPC++_逆向调用QQ Mojo IPC与WeChat XPlugin
CPPC++_现代活动指标
CPPC++_Xournal是一款手写笔记软件,支持PDF注释,使用C语言编写,支持GTK3,支持Linux,如Ubu
资源概述: 本资源提供了一套完整的学生实习管理系统解决方案,涵盖了前台小程序页面与后台管理系统两大模块。前台小程序页面设计简洁直观,用户可根据不同身份(学生或企业)进行登录。学生用户能够方便地浏览并投递感兴趣的实习岗位,而企业用户则能轻松发布实习信息,吸引优秀人才。后台管理系统功能全面,包括个人中心、首页、学生管理、教师管理、企业管理、招聘管理、评分管理以及实习管理等多个方面,为管理员提供了强大的数据管理和操作工具。 技术栈亮点: SSM框架:系统后台采用Spring、Spring MVC和MyBatis Plus(简称SSM)作为核心开发框架,确保了系统的稳定性、可扩展性和可维护性。Spring作为控制反转(IoC)和面向切面编程(AOP)的容器,为系统提供了强大的业务逻辑处理能力;Spring MVC则负责处理Web请求和响应,实现了前后端的分离;MyBatis Plus作为持久层框架,简化了数据库操作,提高了开发效率。 MySQL数据库:系统采用MySQL作为数据库存储解决方案,支持大数据量的存储和高效查询。 如有侵权请联系我删除,谢谢
微服务闪聚支付项目
博客链接 https://blog.csdn.net/weixin_47560078/article/details/143714557 文章从原理介绍出发,实现了 Rust 与 Java 的互调。利用 JNI 技术,可以充分发挥 Rust 的性能优势,同时保持 Java 的跨平台特性。这种技术组合适用于对性能要求较高的应用场景,如图像处理、数据分析和系统级编程等。
cppc++
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 替换数据可以直接使用,注释清楚,适合新手
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 替换数据可以直接使用,注释清楚,适合新手
分布式事务lcn
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
cppc++
安卓手机与电脑的socket通信源码
Anaconda:JupyterNotebook使用教程.docx
Amazon S3:S3静态网站托管教程.docx
Python商品销售数据分析可视化项目源码(期末大作业).zip,个人经导师指导并认可通过的98分大作业设计项目。主要针对计算机相关专业的正在做期末大作业设计的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业,代码资料完整下载可用。 Python商品销售数据分析可视化项目源码(期末大作业).zip,个人经导师指导并认可通过的98分大作业设计项目。主要针对计算机相关专业的正在做期末大作业设计的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业,代码资料完整下载可用。Python商品销售数据分析可视化项目源码(期末大作业).zip,个人经导师指导并认可通过的98分大作业设计项目。主要针对计算机相关专业的正在做期末大作业设计的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业,代码资料完整下载可用。Python商品销售数据分析可视化项目源码(期末大作业).zip,个人经导师指导并认可通过的98分大作业设计项目。主要针对计算机相关专业的正在做期末大作业设计的学生和需要项目实战练习的学习者,可作为课程设计、期末大作业,代码资料完整下载可用。Python商品销售数据分析
CPPC++_wechathookWeChatApi微信Api微信hook微信接口python微信接口java微信Ap