private static FMOD.RESULT FMOD_EVENT_CALLBACK(IntPtr eventraw, FMOD.EVENT_CALLBACKTYPE type, IntPtr param1, IntPtr param2, IntPtr userdata)
        {
            unsafe
            {
                switch (type)
                {
                case FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_CREATE:
                {
                    int   entryindex  = *(int *)param2.ToPointer();        // [in]  (int) index of sound definition entry
                    uint *realpointer = (uint *)param2.ToPointer();        // [out] (FMOD::Sound *) a valid lower level API FMOD Sound handle

                    FMOD.Sound s = null;
                    fsb.getSubSound(entryindex, ref s);

                    *realpointer = (uint)s.getRaw().ToPointer();

                    break;
                }

                case FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_RELEASE:
                {
                    break;
                }
                }
            }
            return(FMOD.RESULT.OK);
        }
Пример #2
0
    static FMOD.RESULT EventStoppedCallbackStatic(IntPtr eventraw, FMOD.EVENT_CALLBACKTYPE type, IntPtr param1, IntPtr param2, IntPtr userdata)
    {
        GCHandle             handle = (GCHandle)userdata;
        FmodEventAudioSource src    = (handle.Target as FmodEventAudioSource);

        return(src.EventStoppedCallback(type, param1, param2));
    }
Пример #3
0
    FMOD.RESULT EventStoppedCallback(FMOD.EVENT_CALLBACKTYPE type, IntPtr param1, IntPtr param2)
    {
        FMOD.RESULT result = FMOD.RESULT.OK;

        if (EventCallback != null)
        {
            EventCallback(this, type, param1, param2);
        }
        //		Debug.Log ("event: " + m_source.getName() + "; name: " + name + "; type: " + type);
        if (type == FMOD.EVENT_CALLBACKTYPE.EVENTSTARTED)
        {
            m_allSources.Add(this);             // adding the event to the list only here means paused events will appear as active... we'll see if anyone complains. it such is the case; we should also add/remove in OnEnable and OnDisable
            m_status = Status.Playing;

            // the code below should fire event for all listeners
            if (EventStarted != null)
            {
                EventStarted(this);
            }
        }
        else if (type == FMOD.EVENT_CALLBACKTYPE.EVENTFINISHED)
        {
            m_status = Status.Stopped;
            m_allSources.Remove(this);
            if (EventFinished != null)
            {
                EventFinished(this);
            }
        }
        else if (type == FMOD.EVENT_CALLBACKTYPE.STOLEN)
        {
            FMOD.RESULT tmp = FMOD.RESULT.OK;

            if (EventStolen != null)
            {
                foreach (Delegate del in EventStolen.GetInvocationList())
                {
                    tmp = (FMOD.RESULT)del.DynamicInvoke(this);
                    if (tmp != FMOD.RESULT.OK)
                    {
                        result = tmp;
                    }
                }
            }
            if (result != FMOD.RESULT.ERR_EVENT_FAILED)
            {
                cleanInvalidHandle();
            }
        }
        else if (type == FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_START)
        {
            string name = Marshal.PtrToStringAnsi(param1);
            int    waveIndexInSoundDef = param2.ToInt32();

            if (SoundDefStart != null)
            {
                SoundDefStart(this, name, waveIndexInSoundDef);
            }
        }
        else if (type == FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_END)
        {
            string name = Marshal.PtrToStringAnsi(param1);
            int    waveIndexInSoundDef = param2.ToInt32();

            if (SoundDefEnd != null)
            {
                SoundDefEnd(this, name, waveIndexInSoundDef);
            }
        }
        return(result);
    }