Example #1
0
    public static void CleanupOneshotEvents(List <FMODCommon.OneshotEventInfo> oneshotEvents, bool useMaximumAge)
    {
        int i = 0;

        while (i < oneshotEvents.Count)
        {
            FMODCommon.OneshotEventInfo oneshotEventInfo = oneshotEvents[i];
            PLAYBACK_STATE playback_STATE;
            UnityUtil.ERRCHECK(oneshotEventInfo.instance.getPlaybackState(out playback_STATE));
            bool flag = false;
            if (playback_STATE == PLAYBACK_STATE.STOPPED)
            {
                flag = true;
            }
            if (!flag)
            {
                if (oneshotEventInfo.channelGroup == null)
                {
                    oneshotEventInfo.instance.getChannelGroup(out oneshotEventInfo.channelGroup);
                }
                if (oneshotEventInfo.channelGroup != null)
                {
                    int num = FMODCommon.CountChannels(oneshotEventInfo.channelGroup);
                    if (num > 0)
                    {
                        oneshotEventInfo.hasStarted = true;
                    }
                    else if (oneshotEventInfo.hasStarted)
                    {
                        UnityUtil.ERRCHECK(oneshotEventInfo.instance.stop(STOP_MODE.IMMEDIATE));
                        flag = true;
                    }
                }
            }
            if (!flag && useMaximumAge && oneshotEventInfo.useMaximumAge)
            {
                float num2 = Time.time - oneshotEventInfo.startTime;
                if (num2 > 10f)
                {
                    UnityUtil.ERRCHECK(oneshotEventInfo.instance.stop(STOP_MODE.IMMEDIATE));
                    flag = true;
                }
            }
            if (flag)
            {
                UnityUtil.ERRCHECK(oneshotEventInfo.instance.release());
                oneshotEvents.RemoveAt(i);
            }
            else
            {
                i++;
            }
        }
    }
Example #2
0
    public static int CountChannels(ChannelGroup group)
    {
        int num = 0;

        UnityUtil.ERRCHECK(group.getNumChannels(out num));
        int num2 = 0;

        UnityUtil.ERRCHECK(group.getNumGroups(out num2));
        for (int i = 0; i < num2; i++)
        {
            ChannelGroup group2;
            UnityUtil.ERRCHECK(group.getGroup(i, out group2));
            num += FMODCommon.CountChannels(group2);
        }
        return(num);
    }