音声割り込み処理
iOSアプリケーションは、音声割り込み処理を適切に行う必要があります。
プログラム解説:基本再生 では、音声割り込み処理を AtomUtilIOS_AudioSessionNotificationObserverクラスのinterruptionHandler:メソッドに実装しています。
また、interruptionHandler:メソッドを criadx2le::audioSessionInitialize 関数内でデフォルトの NSNotificationCenter に AVAudioSessionInterruptionNotification に対するオブザーバを登録しています。
注意:
iOS6より前のOSではAVAudioSessionではなく、AudioSessionのAPIで対応する必要があります。
AtomUtilIOS_AudioSessionNotificationObserverクラスのinterruptionHandler:メソッド
/* 音声割り込み処理 */
- (void)interruptionHandler: (NSNotification*)notification
{
    int value = [[notification.userInfo valueForKey: AVAudioSessionInterruptionTypeKey] intValue];
    switch (value) {
        case AVAudioSessionInterruptionTypeBegan:
            /* 音声割り込み開始時の処理 */
            /*   ADX2の音声出力を停止 */
            criAtomEx_StopSound_IOS();
            /*   AVAudioSessionをディアクティベート */
            audioSessionSetActive(NO);
            break;
        case AVAudioSessionInterruptionTypeEnded:
        default:
            /* 音声割り込み終了時の処理 */
            /*   AVAudioSessionをアクティベート */
            audioSessionSetActive(YES);
            /*   ADX2の音声出力を開始(再開) */
            criAtomEx_StartSound_IOS();
            break;
    }
}
criadx2le::audioSessionInitialize 関数内
/* NSNotificationCenter にオブザーバを登録 */
NSNotificationCenter* notification_center = [NSNotificationCenter defaultCenter];
AVAudioSession*       audio_session       = [AVAudioSession sharedInstance];
/* AVAudioSessionInterruptionNotification に対するオブザーバとして */
/* interruptionHandler: メソッドを登録する                         */
[notification_center
 addObserver: audiosession_notification_observer
 selector: @selector(interruptionHandler:)
 name: AVAudioSessionInterruptionNotification
 object: audio_session
 ];

CRI Middleware logo Copyright (c) 2012-2018 CRI Middleware Co., Ltd. CRI ADX2 LE マニュアル (for Cocos2d-x) SDKVer.2.10版