- 浏览: 87702 次
- 性别:
- 来自: 昆明
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 2717原因:Xcode 6 默认新建的启动页面为 LaunchScr ... -
怎么创建 UITableViewCell 的 xib
2014-10-27 13:08 4601. 新建文件,选择 User Interface->V ... -
iOS 调试问题小结
2014-06-12 11:17 7011. XCode 提示 ”set a breakpoint i ... -
Could not launch " app name"
2013-12-19 11:11 619“could not launch app name” ... -
Why iOS 5.x doesn't work under Maverick
2013-12-19 09:52 633The iOS simulator does not dupl ... -
How to know whether a project uses ARC
2013-12-17 11:17 630There are 2 method to check whe ... -
把 iOS app logs 写入 documents 文件夹
2013-12-06 17:15 990Now, in order to tell your app ... -
用 lipo 命令裁剪出需要的 architecture
2013-11-06 15:23 1377iOS 上的 framework 和 .a 库一般会同 ... -
写文件,真机和模拟器是不一样的
2013-10-17 22:30 477在真机上,只能往 Documents 和 tmp ... -
setValue:forUndefinedKey
2013-10-15 09:54 735使用 Storyboard 创建并管理 UI 时,在运行 ... -
创建 Empty Application时, storyboard 不显示的问题
2013-10-15 09:49 1133原因: 1. 创建 Empty Application 时没有 ... -
OC 和 C++ 混编
2013-10-08 15:45 739原文出处: http://blog.csdn.net ... -
Objective-C 中,@class & #import 的区别
2013-09-29 10:38 581Key points: "#Import&q ... -
Xcode如何打包ipa安装包
2013-09-05 11:41 1444http://jingyan.baidu.com/articl ... -
iOS 与 Armv6 Armv7 i386
2013-08-23 16:39 1160[size=medium]Armv6 binaries ... -
Difference: Category and Protocol
2013-07-14 16:45 581http://www.cnblogs.com/chijianq ... -
iOS 查看各个函数的执行顺序
2013-01-04 16:10 898- (BOOL)respondsToSelector:(SEL ... -
HOW TO ADD PHOTOS TO THE IPHONE SIMULATOR
2012-12-25 15:49 736Building an app that needs to a ... -
AutoReleasePool 学习笔记
2012-11-14 18:49 6711. In a reference-counted envir ...
相关推荐
ta_lib-0.5.1-cp312-cp312-win32.whl
课程设计 在线实时的斗兽棋游戏,时间赶,粗暴的使用jQuery + websoket 实现实时H5对战游戏 + java.zip课程设计
ta_lib-0.5.1-cp310-cp310-win_amd64.whl
基于springboot+vue物流系统源码数据库文档.zip
GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载
知识图谱
333498005787635解决keil下载失败的文件.zip
【微信机器人原理与实现】 微信机器人是通过模拟微信客户端的行为,自动处理消息、发送消息的程序。在Python中实现微信机器人的主要库是WeChatBot,它提供了丰富的接口,允许开发者方便地进行微信消息的接收与发送。这个项目标题中的"基于python实现的微信机器人源码"指的是使用Python编程语言编写的微信机器人程序。 1. **Python基础**:Python是一种高级编程语言,以其简洁的语法和强大的功能深受开发者喜爱。在实现微信机器人时,你需要熟悉Python的基本语法、数据类型、函数、类以及异常处理等概念。 2. **微信API与WeChatBot库**:微信为开发者提供了微信公共平台和微信开放平台,可以获取到必要的API来实现机器人功能。WeChatBot库是Python中一个用于微信开发的第三方库,它封装了微信的API,简化了消息处理的流程。使用WeChatBot,开发者可以快速搭建起一个微信机器人。 3. **微信OAuth2.0授权**:为了能够接入微信,首先需要通过OAuth2.0协议获取用户的授权。用户授权后,机器人可以获取到微信用户的身份信息,从而进行
基于springboot实验室研究生信息管理系统源码数据库文档.zip
张力控制,色标跟踪,多轴同步,电子凸轮,横切等工艺控制案例。
在Python编程环境中,处理Microsoft Word文档是一项常见的任务。Python提供了几个库来实现这一目标,如`python-docx`,它可以让我们创建、修改和操作.docx文件。本教程将重点介绍如何利用Python进行Word文档的合并、格式转换以及转换为PDF。 1. **合并Word文档(merge4docx)** 合并多个Word文档是一项实用的功能,特别是在处理大量报告或文档集合时。在Python中,可以使用`python-docx`库实现。我们需要导入`docx`模块,然后读取每个文档并将其内容插入到主文档中。以下是一个基本示例: ```python from docx import Document def merge4docx(file_list, output_file): main_doc = Document() for file in file_list: doc = Document(file) for paragraph in doc.paragraphs: main_doc.add_paragraph(paragraph.text) m
基于springboot+Javaweb的二手图书交易系统源码数据库文档.zip
基于springboot餐品美食论坛源码数据库文档.zip
基于springboot亚运会志愿者管理系统源码数据库文档.zip
使用WPF的数据样式绑定,切换对象数据值来完成控件动态切换背景渐变动画效果。 使用动画样式渲染比线程修改性能消耗更低更稳定
基于SpringBoot的企业客源关系管理系统源码数据库文档.zip
基于springboot+vue的桂林旅游网站系统源码数据库文档.zip
基于springboot嗨玩旅游网站源码数据库文档.zip
基于springboot的流浪动物管理系统源码数据库文档.zip
基于springboot课件通中小学教学课件共享平台源码数据库文档.zip