ERRCHECK() static private méthode

static private ERRCHECK ( FMOD result ) : bool
result FMOD
Résultat bool
Exemple #1
0
    public EventInstance GetEvent(string path)
    {
        EventInstance eventInstance = null;

        if (string.IsNullOrEmpty(path))
        {
            UnityUtil.LogError("Empty event path!");
            return(null);
        }
        if (this.eventDescriptions.ContainsKey(path))
        {
            FMOD_StudioSystem.ERRCHECK(this.eventDescriptions[path].createInstance(out eventInstance));
        }
        else
        {
            EventDescription eventDescription = null;
            FMOD_StudioSystem.ERRCHECK(this.system.getEvent(path, out eventDescription));
            if (eventDescription != null && eventDescription.isValid())
            {
                this.eventDescriptions.Add(path, eventDescription);
                FMOD_StudioSystem.ERRCHECK(eventDescription.createInstance(out eventInstance));
            }
        }
        if (eventInstance == null)
        {
            UnityUtil.Log("GetEvent FAILED: \"" + path + "\"");
        }
        return(eventInstance);
    }
Exemple #2
0
 private void Update()
 {
     if (FMOD_StudioSystem.isInitialized && this.system != null)
     {
         FMOD_StudioSystem.ERRCHECK(this.system.update());
     }
 }
Exemple #3
0
 private void Update()
 {
     if (this.isInitialized)
     {
         FMOD_StudioSystem.ERRCHECK(this.system.update());
     }
 }
Exemple #4
0
 private void OnDisable()
 {
     if (this.isInitialized)
     {
         UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
         FMOD_StudioSystem.ERRCHECK(this.system.release());
     }
 }
Exemple #5
0
    public Bus GetBus(string strBus)
    {
        Bus bus = null;

        FMOD_StudioSystem.ERRCHECK(this.system.getBus(strBus, out bus));
        if (bus == null)
        {
            UnityUtil.Log("GetBus FAILED!!!");
        }
        return(bus);
    }
Exemple #6
0
    public VCA GetVCA(string path)
    {
        VCA vCA = null;

        FMOD_StudioSystem.ERRCHECK(this.system.getVCA(path, out vCA));
        if (vCA == null)
        {
            UnityUtil.Log("GetVCA FAILED!!!");
        }
        return(vCA);
    }
Exemple #7
0
 public void OutputEventsInfo()
 {
     UnityEngine.Debug.Log("<color=yellow>------------------------- OutputEventsInfo -------------------------</color>");
     UnityEngine.Debug.Log("events cnt: " + this.eventDescriptions.Count);
     foreach (KeyValuePair <string, EventDescription> current in this.eventDescriptions)
     {
         bool flag;
         FMOD_StudioSystem.ERRCHECK(current.Value.is3D(out flag));
         bool flag2;
         FMOD_StudioSystem.ERRCHECK(current.Value.isStream(out flag2));
         EventInstance[] array;
         FMOD_StudioSystem.ERRCHECK(current.Value.getInstanceList(out array));
         string text = "instance info:";
         if (array != null && array.Length > 0)
         {
             for (int i = 0; i < array.Length; i++)
             {
                 EventDescription eventDescription;
                 array[i].getDescription(out eventDescription);
                 string str;
                 eventDescription.getPath(out str);
                 text = text + str + " ";
             }
             UnityEngine.Debug.Log(string.Concat(new object[]
             {
                 "key: ",
                 current.Key,
                 " 3d:",
                 flag,
                 " isstream:",
                 flag2,
                 " instances cnt:",
                 array.Length,
                 " detail: ",
                 text
             }));
         }
         else
         {
             UnityEngine.Debug.Log(string.Concat(new object[]
             {
                 "key: ",
                 current.Key,
                 " 3d:",
                 flag,
                 " isstream:",
                 flag2,
                 " instances cnt:0"
             }));
         }
     }
 }
Exemple #8
0
    public void PlayOneShot(string path, Vector3 position, float volume)
    {
        EventInstance @event = this.GetEvent(path);

        if (@event == null)
        {
            UnityUtil.LogWarning("PlayOneShot couldn't find event: \"" + path + "\"");
            return;
        }
        FMOD.Studio.ATTRIBUTES_3D attributes = position.to3DAttributes();
        FMOD_StudioSystem.ERRCHECK(@event.set3DAttributes(attributes));
        FMOD_StudioSystem.ERRCHECK(@event.setVolume(volume));
        FMOD_StudioSystem.ERRCHECK(@event.start());
        FMOD_StudioSystem.ERRCHECK(@event.release());
    }
Exemple #9
0
    private EventInstance PlayOneShot(string path, Vector3 position, float volume, FMOD_StudioSystem.ProcessEventInstanceDelegate eventSetup = null)
    {
        if (this.ShouldBeCulled(path, position))
        {
            return(null);
        }
        EventInstance @event = this.GetEvent(path);

        FMOD.Studio.ATTRIBUTES_3D attributes = position.to3DAttributes();
        FMOD_StudioSystem.ERRCHECK(@event.set3DAttributes(attributes));
        if (eventSetup == null || eventSetup(@event))
        {
            FMOD_StudioSystem.ERRCHECK(@event.start());
        }
        FMOD_StudioSystem.ERRCHECK(@event.release());
        return(@event);
    }
Exemple #10
0
 private void OnApplicationPause(bool pauseStatus)
 {
     if (this.system != null)
     {
         FMOD.System system;
         FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
         UnityUtil.Log("Pause state changed to: " + pauseStatus);
         if (pauseStatus)
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerSuspend());
         }
         else
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerResume());
         }
     }
 }
Exemple #11
0
    private void Init()
    {
        UnityUtil.Log("FMOD_StudioSystem: Initialize");
        if (FMOD_StudioSystem.isInitialized)
        {
            return;
        }
        UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
        UnityUtil.Log("FMOD_StudioSystem: System_Create");
        FMOD_StudioSystem.ERRCHECK(FMOD.Studio.System.create(out this.system));
        FMOD.Studio.INITFLAGS iNITFLAGS = FMOD.Studio.INITFLAGS.NORMAL;
        FMOD.System           system;
        FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
        FMOD.ADVANCEDSETTINGS aDVANCEDSETTINGS = default(FMOD.ADVANCEDSETTINGS);
        aDVANCEDSETTINGS.randomSeed = (uint)DateTime.Now.Ticks;
        FMOD_StudioSystem.ERRCHECK(system.setAdvancedSettings(ref aDVANCEDSETTINGS));
        UnityUtil.Log("FMOD_StudioSystem: system.init");
        RESULT rESULT = this.system.initialize(1024, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);

        if (rESULT == RESULT.ERR_HEADER_MISMATCH)
        {
            UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            FMOD_StudioSystem.ERRCHECK(rESULT);
        }
        FMOD_StudioSystem.ERRCHECK(this.system.flushCommands());
        rESULT = this.system.update();
        if (rESULT == RESULT.ERR_NET_SOCKET_ERROR)
        {
            UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            iNITFLAGS &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            FMOD_StudioSystem.ERRCHECK(this.system.release());
            FMOD_StudioSystem.ERRCHECK(FMOD.Studio.System.create(out this.system));
            FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
            aDVANCEDSETTINGS            = default(FMOD.ADVANCEDSETTINGS);
            aDVANCEDSETTINGS.randomSeed = (uint)DateTime.Now.Ticks;
            FMOD_StudioSystem.ERRCHECK(system.setAdvancedSettings(ref aDVANCEDSETTINGS));
            rESULT = this.system.initialize(1024, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
            FMOD_StudioSystem.ERRCHECK(rESULT);
        }
        FMOD_StudioSystem.isInitialized = true;
    }
Exemple #12
0
    public EventInstance GetEvent(string path)
    {
        EventInstance eventInstance = null;

        if (string.IsNullOrEmpty(path))
        {
            UnityUtil.LogError("Empty event path!");
            return(null);
        }
        if (this.eventDescriptions.ContainsKey(path) && this.eventDescriptions[path].isValid())
        {
            FMOD_StudioSystem.ERRCHECK(this.eventDescriptions[path].createInstance(out eventInstance));
        }
        else
        {
            Guid guid = default(Guid);
            if (path.StartsWith("{"))
            {
                FMOD_StudioSystem.ERRCHECK(Util.ParseID(path, out guid));
            }
            else if (path.StartsWith("event:") || path.StartsWith("snapshot:"))
            {
                FMOD_StudioSystem.ERRCHECK(this.system.lookupID(path, out guid));
            }
            else
            {
                UnityUtil.LogError("Expected event path to start with 'event:/' or 'snapshot:/'");
            }
            EventDescription eventDescription = null;
            FMOD_StudioSystem.ERRCHECK(this.system.getEventByID(guid, out eventDescription));
            if (eventDescription != null && eventDescription.isValid())
            {
                this.eventDescriptions[path] = eventDescription;
                FMOD_StudioSystem.ERRCHECK(eventDescription.createInstance(out eventInstance));
            }
        }
        if (eventInstance == null)
        {
            UnityUtil.Log("GetEvent FAILED: \"" + path + "\"");
        }
        return(eventInstance);
    }
Exemple #13
0
    void LoadPlugins()
    {
        FMOD.System sys = null;
        FMOD_StudioSystem.ERRCHECK(FMOD_StudioSystem.instance.System.getLowLevelSystem(out sys));

        var dir = pluginPath;

        foreach (var name in pluginPaths)
        {
            var path = dir + "/" + GetPluginFileName(name);

            //Debug.Log("Loading plugin: " + path);
            if (!System.IO.File.Exists(path))
            {
                Debug.LogWarning("plugin not found: " + path);
            }

            uint handle = 0;
            FMOD_StudioSystem.ERRCHECK(sys.loadPlugin(path, ref handle));
        }
    }
Exemple #14
0
    public EventDescription GetEventDescription(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            UnityUtil.LogError("Empty event path!");
        }
        if (this.eventDescriptions.ContainsKey(path))
        {
            return(this.eventDescriptions[path]);
        }
        EventDescription eventDescription = null;
        RESULT           @event           = this.system.getEvent(path, out eventDescription);

        if (@event == RESULT.OK)
        {
            this.eventDescriptions.Add(path, eventDescription);
            return(eventDescription);
        }
        FMOD_StudioSystem.ERRCHECK(@event);
        UnityUtil.LogWarning("Error getting event with path \"" + path + "\"");
        return(null);
    }
Exemple #15
0
    public static void UnPreloadEvent(string path, int unloadCount)
    {
        if (FMOD_StudioSystem.sInstance == null)
        {
            return;
        }
        if (path.Length == 0)
        {
            return;
        }
        EventDescription eventDescription = FMOD_StudioSystem.sInstance.GetEventDescription(path);

        if (eventDescription == null)
        {
            UnityUtil.LogWarning("UnPreload failed for \"" + path + "\"");
            return;
        }
        for (int i = 0; i < unloadCount; i++)
        {
            FMOD_StudioSystem.ERRCHECK(eventDescription.unloadSampleData());
        }
    }
Exemple #16
0
 private void OnApplicationPause(bool pauseStatus)
 {
     if (this.system != null && this.system.isValid())
     {
         UnityUtil.Log("Pause state changed to: " + pauseStatus);
         FMOD.System system;
         FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
         if (system == null)
         {
             UnityUtil.LogError("Tried to suspend mixer, but no low level system found");
             return;
         }
         if (pauseStatus)
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerSuspend());
         }
         else
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerResume());
         }
     }
 }
Exemple #17
0
 public void UnloadAllEventsInstances()
 {
     UnityEngine.Debug.Log("<color=yellow>------------------------- UnloadAllEventsInstances -------------------------</color>");
     foreach (KeyValuePair <string, EventDescription> current in this.eventDescriptions)
     {
         EventInstance[] array;
         FMOD_StudioSystem.ERRCHECK(current.Value.getInstanceList(out array));
         if (array != null)
         {
             for (int i = 0; i < array.Length; i++)
             {
                 array[i].release();
             }
             UnityEngine.Debug.Log(string.Concat(new object[]
             {
                 "key: ",
                 current.Key,
                 " instance cnt:",
                 array.Length
             }));
         }
     }
 }
Exemple #18
0
    public void OutputCurrEventsInfo()
    {
        UnityEngine.Debug.Log("<color=yellow>------------------------- OutputCurrEventsInfo -------------------------</color>");
        int num = 0;

        foreach (KeyValuePair <string, EventDescription> current in this.eventDescriptions)
        {
            int num2 = 0;
            FMOD_StudioSystem.ERRCHECK(current.Value.getInstanceCount(out num2));
            if (num2 > 0)
            {
                UnityEngine.Debug.Log(string.Concat(new object[]
                {
                    "key: ",
                    current.Key,
                    " instance cnt:",
                    num2
                }));
                num++;
            }
        }
        UnityEngine.Debug.Log("RESULT, CNT IS: " + num);
    }
Exemple #19
0
    public bool ShouldBeCulled(string path, Vector3 position)
    {
        EventDescription eventDescription = this.GetEventDescription(path);

        if (eventDescription == null)
        {
            return(true);
        }
        bool flag = false;

        FMOD_StudioSystem.ERRCHECK(eventDescription.is3D(out flag));
        if (flag)
        {
            float num = 0f;
            FMOD_StudioSystem.ERRCHECK(eventDescription.getMaximumDistance(out num));
            num += 20f;
            FMOD.Studio.ATTRIBUTES_3D aTTRIBUTES_3D;
            FMOD_StudioSystem.ERRCHECK(this.System.getListenerAttributes(0, out aTTRIBUTES_3D));
            float sqrMagnitude = (position - aTTRIBUTES_3D.position.toUnityVector()).sqrMagnitude;
            float num2         = num * num;
            return(sqrMagnitude > num2);
        }
        return(false);
    }
Exemple #20
0
 void ERRCHECK(FMOD.RESULT result)
 {
     FMOD_StudioSystem.ERRCHECK(result);
 }
Exemple #21
0
 FMOD.RESULT ERRCHECK(FMOD.RESULT result)
 {
     FMOD_StudioSystem.ERRCHECK(result);
     return(result);
 }
Exemple #22
0
    private void Init()
    {
        UnityUtil.Log("FMOD_StudioSystem: Initialize");
        if (this.isInitialized)
        {
            return;
        }
        UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
        this.LiveUpdateEnabled = false;
        string[] commandLineArgs = Environment.GetCommandLineArgs();
        for (int i = 0; i < commandLineArgs.Length; i++)
        {
            string a = commandLineArgs[i];
            if (a == "-FMODLiveUpdate")
            {
                this.LiveUpdateEnabled = true;
                break;
            }
        }
        UnityUtil.Log("FMOD_StudioSystem: System_Create");
        FMOD_StudioSystem.ERRCHECK(FMOD.Studio.System.create(out this.system));
        FMOD.Studio.INITFLAGS iNITFLAGS        = FMOD.Studio.INITFLAGS.NORMAL;
        FMOD.ADVANCEDSETTINGS aDVANCEDSETTINGS = default(FMOD.ADVANCEDSETTINGS);
        if (this.LiveUpdateEnabled)
        {
            iNITFLAGS |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
            if (Application.unityVersion.StartsWith("5"))
            {
                UnityUtil.LogWarning("FMOD_StudioSystem: detected Unity 5, running on port 9265");
                aDVANCEDSETTINGS.profilePort = 9265;
            }
        }
        int @int = PlayerPrefs.GetInt("VoiceCount", 128);

        FMOD.System system;
        FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
        FMOD_StudioSystem.ERRCHECK(system.setSoftwareChannels(@int));
        aDVANCEDSETTINGS.maxVorbisCodecs = @int;
        FMOD_StudioSystem.ERRCHECK(system.setAdvancedSettings(ref aDVANCEDSETTINGS));
        int           num  = 48000;
        StringBuilder name = new StringBuilder();
        Guid          guid;
        SPEAKERMODE   sPEAKERMODE;
        int           num2;

        FMOD_StudioSystem.ERRCHECK(system.getDriverInfo(0, name, 0, out guid, out num, out sPEAKERMODE, out num2));
        if (num > 48000)
        {
            uint bufferlength = 0u;
            int  num3         = 0;
            FMOD_StudioSystem.ERRCHECK(system.getDSPBufferSize(out bufferlength, out num3));
            FMOD_StudioSystem.ERRCHECK(system.setDSPBufferSize(bufferlength, num3 * 2));
        }
        num = Math.Min(num, 48000);
        FMOD_StudioSystem.ERRCHECK(system.setSoftwareFormat(num, SPEAKERMODE._5POINT1, 0));
        UnityUtil.Log("FMOD_StudioSystem: system.init");
        RESULT rESULT = this.system.initialize(1024, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);

        if (rESULT == RESULT.ERR_NET_SOCKET_ERROR)
        {
            UnityUtil.LogError("Unable to initalize with LiveUpdate: socket is already in use");
        }
        else if (rESULT == RESULT.ERR_HEADER_MISMATCH)
        {
            UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            FMOD_StudioSystem.ERRCHECK(rESULT);
        }
        this.isInitialized = true;
    }