使用OpenAL时是否有可能“躲避”AudioSession?

时间:2013-03-24 19:27:18

标签: iphone ios cocoa-touch openal audiosession

有人知道这是否可行?

我的音频会话和OpenAL设置如下:

// Allow their music to play in the background
AudioSessionInitialize(NULL, NULL, openALInterruptionListener, (__bridge void *)(self));

UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);

UInt32 allowMixing = false;
AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(allowMixing), &allowMixing);

//      use the device to make a context
_mContext = alcCreateContext(_mDevice, NULL);
//      set my context to the currently active one
alcMakeContextCurrent(_mContext);

我有这样的设置:

- (void)setSoundDucked:(BOOL)soundDucked
{    
    if(soundDucked)
    {
        UInt32 allowMixing = true;
        AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck,     sizeof(allowMixing), &allowMixing);
        AudioSessionSetActive(false);
        AudioSessionSetActive(true);
    }
    else
    {
        UInt32 allowMixing = false;
        AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(allowMixing), &allowMixing);
        AudioSessionSetActive(false);
        AudioSessionSetActive(true);
    }
}

然而,声音不会消失。如果我注释掉以下几行,它只会躲避:

//      use the device to make a context
_mContext = alcCreateContext(_mDevice, NULL);
//      set my context to the currently active one
alcMakeContextCurrent(_mContext);

有没有让OpenAL与音频闪避属性玩得很好?

0 个答案:

没有答案