1

有人知道这是否可能吗?

我的音频会话和 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 与音频闪避属性一起玩得很好?

4

0 回答 0