AudioStreamer电话时crash
2014-01-10 14:57
1211 查看
crash时定位在AudioStreamer:
staticvoid ASAudioSessionInterruptionListener(void *inClientData,UInt32
inInterruptionState)
{
AudioStreamer* streamer = (AudioStreamer *)inClientData;
[streamerhandleInterruptionChangeToState:inInterruptionState];
}
我们可以换一种实现方式:
AudioSessionInitialize (
NULL, // 'NULL' to use the default (main) run loop
NULL, // 'NULL' to use the default run loop mode
ASAudioSessionInterruptionListener, // a reference to your interruption callback
self // data to pass to your interruption listener callback
);
替换成
AVAudioSession *mySession = [AVAudioSessionsharedInstance];
// Specify that this object is the delegate of the audio session, so that
// this object's endInterruption method will be invoked when needed.
[mySession
setDelegate:self];
且实现以下方法:
- (void) beginInterruption {
if ([self
isPlaying]) {
[selfpause];
pausedByInterruption =YES;
}
}
NSError *activationError =nil;
- (void) endInterruption {
AudioSessionSetActive(true );
if ([selfisPaused]
&&pausedByInterruption) {
[selfpause];
// this is actually resume
pausedByInterruption =NO;
// this is redundant
}
}
staticvoid ASAudioSessionInterruptionListener(void *inClientData,UInt32
inInterruptionState)
{
AudioStreamer* streamer = (AudioStreamer *)inClientData;
[streamerhandleInterruptionChangeToState:inInterruptionState];
}
我们可以换一种实现方式:
AudioSessionInitialize (
NULL, // 'NULL' to use the default (main) run loop
NULL, // 'NULL' to use the default run loop mode
ASAudioSessionInterruptionListener, // a reference to your interruption callback
self // data to pass to your interruption listener callback
);
替换成
AVAudioSession *mySession = [AVAudioSessionsharedInstance];
// Specify that this object is the delegate of the audio session, so that
// this object's endInterruption method will be invoked when needed.
[mySession
setDelegate:self];
且实现以下方法:
- (void) beginInterruption {
if ([self
isPlaying]) {
[selfpause];
pausedByInterruption =YES;
}
}
NSError *activationError =nil;
- (void) endInterruption {
AudioSessionSetActive(true );
if ([selfisPaused]
&&pausedByInterruption) {
[selfpause];
// this is actually resume
pausedByInterruption =NO;
// this is redundant
}
}
相关文章推荐
- AudioStreamer电话打进时崩溃
- 准确定位程序Crash时所对应的源代码行(一)
- Android中Crash收集
- Android核心分析之十六Android电话系统-概述篇
- iOS中的crash防护(二)KVC造成的crash
- [转载]定位程序Crash常用工具和方法
- Android常见CRASH
- 正则表达式之电话,邮箱,邮编篇
- iOS---------Apple 提供给开发者的电话服务
- kernel启动控制台还不可用时发生crash的调试方法
- 11-散列1 电话聊天狂人 (25分)
- iOS 拨打电话相关知识总结
- 使用安卓* 电话通过英特尔® Edison的蓝牙串行端口 (SPP) 与Arduino代码通信
- cvUndistort2 () and cvRemap () crash
- android蓝牙电话监听状态
- 微信骗子 QQ7492593 电话 18627650031 这个骗子骗我4000块钱
- 用BroadcastReceiver实现广播的电话拦截
- Linux内核调试:kdump、vmcore、crash、kernel-debuginfo
- Android - 在线浏览源码,电话短信相关,文本变化监听器,Interpolator,WindowManager
- 实现电话自动拨打、挂断