setAdvancedSettings() публичный Метод

public setAdvancedSettings ( ADVANCEDSETTINGS &settings ) : RESULT
settings ADVANCEDSETTINGS
Результат RESULT
Пример #1
0
        private RESULT Initialize()
        {
            initializedSuccessfully = false;
            RESULT   rESULT   = RESULT.OK;
            RESULT   rESULT2  = RESULT.OK;
            Settings settings = Settings.Instance;

            fmodPlatform = RuntimeUtils.GetCurrentPlatform();
            int         sampleRate      = settings.GetSampleRate(fmodPlatform);
            int         num             = Math.Min(settings.GetRealChannels(fmodPlatform), 256);
            int         virtualChannels = settings.GetVirtualChannels(fmodPlatform);
            SPEAKERMODE speakerMode     = (SPEAKERMODE)settings.GetSpeakerMode(fmodPlatform);
            OUTPUTTYPE  output          = OUTPUTTYPE.AUTODETECT;

            FMOD.ADVANCEDSETTINGS settings2 = default(FMOD.ADVANCEDSETTINGS);
            settings2.randomSeed      = (uint)DateTime.Now.Ticks;
            settings2.maxVorbisCodecs = num;
            FMOD.Studio.INITFLAGS iNITFLAGS = FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
            if (settings.IsLiveUpdateEnabled(fmodPlatform))
            {
                iNITFLAGS |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
            }
            while (true)
            {
                rESULT = FMOD.Studio.System.create(out studioSystem);
                CheckInitResult(rESULT, "FMOD.Studio.System.create");
                rESULT = studioSystem.getLowLevelSystem(out lowlevelSystem);
                CheckInitResult(rESULT, "FMOD.Studio.System.getLowLevelSystem");
                rESULT = lowlevelSystem.setOutput(output);
                CheckInitResult(rESULT, "FMOD.System.setOutput");
                rESULT = lowlevelSystem.setSoftwareChannels(num);
                CheckInitResult(rESULT, "FMOD.System.setSoftwareChannels");
                rESULT = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0);
                CheckInitResult(rESULT, "FMOD.System.setSoftwareFormat");
                rESULT = lowlevelSystem.setAdvancedSettings(ref settings2);
                CheckInitResult(rESULT, "FMOD.System.setAdvancedSettings");
                rESULT = studioSystem.initialize(virtualChannels, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
                if (rESULT != 0 && rESULT2 == RESULT.OK)
                {
                    rESULT2 = rESULT;
                    output  = OUTPUTTYPE.NOSOUND;
                    Debug.LogWarningFormat("FMOD Studio: Studio::System::initialize returned {0}, defaulting to no-sound mode.", rESULT.ToString());
                }
                else
                {
                    CheckInitResult(rESULT, "Studio::System::initialize");
                    if ((iNITFLAGS & FMOD.Studio.INITFLAGS.LIVEUPDATE) == FMOD.Studio.INITFLAGS.NORMAL)
                    {
                        break;
                    }
                    studioSystem.flushCommands();
                    rESULT = studioSystem.update();
                    if (rESULT != RESULT.ERR_NET_SOCKET_ERROR)
                    {
                        break;
                    }
                    iNITFLAGS = (FMOD.Studio.INITFLAGS)((int)iNITFLAGS & -2);
                    Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update (in-use), restarting with Live Update disabled.");
                    rESULT = studioSystem.release();
                    CheckInitResult(rESULT, "FMOD.Studio.System.Release");
                }
            }
            LoadPlugins(settings);
            LoadBanks(settings);
            initializedSuccessfully = (rESULT == RESULT.OK);
            return(rESULT2);
        }
Пример #2
0
        public void SetAdvancedSettings(AdvancedInitializationSettings advancedInitializationSettings)
        {
            var init = advancedInitializationSettings.ToFmod();

            _system.setAdvancedSettings(ref init).Check();
        }
Пример #3
0
        FMOD.RESULT Initialize()
        {
            #if UNITY_EDITOR
                #if UNITY_2017_2_OR_NEWER
            EditorApplication.playModeStateChanged += HandlePlayModeStateChange;
                #elif UNITY_2017_1_OR_NEWER
            EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
                #endif // UNITY_2017_2_OR_NEWER
            #endif     // UNITY_EDITOR

            FMOD.RESULT result       = FMOD.RESULT.OK;
            FMOD.RESULT initResult   = FMOD.RESULT.OK;
            Settings    fmodSettings = Settings.Instance;
            fmodPlatform = RuntimeUtils.GetCurrentPlatform();

            int sampleRate               = fmodSettings.GetSampleRate(fmodPlatform);
            int realChannels             = Math.Min(fmodSettings.GetRealChannels(fmodPlatform), 256); // Prior to 1.08.10 we didn't clamp this properly in the settings screen
            int virtualChannels          = fmodSettings.GetVirtualChannels(fmodPlatform);
            FMOD.SPEAKERMODE speakerMode = (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform);
            FMOD.OUTPUTTYPE  outputType  = FMOD.OUTPUTTYPE.AUTODETECT;

            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.randomSeed = (uint)DateTime.Now.Ticks;
            #if UNITY_EDITOR || UNITY_STANDALONE
            advancedSettings.maxVorbisCodecs = realChannels;
            #elif UNITY_XBOXONE
            advancedSettings.maxXMACodecs = realChannels;
            #elif UNITY_PS4
            advancedSettings.maxAT9Codecs = realChannels;
            #else
            advancedSettings.maxFADPCMCodecs = realChannels;
            #endif

            SetThreadAffinity();

            #if UNITY_EDITOR || ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && DEVELOPMENT_BUILD)
            result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, RuntimeUtils.LogFileName);
            if (result == FMOD.RESULT.ERR_FILE_NOTFOUND)
            {
                UnityEngine.Debug.LogWarningFormat("FMOD Studio: Cannot open FMOD debug log file '{0}', logs will be missing for this session.", System.IO.Path.Combine(Application.dataPath, RuntimeUtils.LogFileName));
            }
            else
            {
                CheckInitResult(result, "FMOD.Debug.Initialize");
            }
            #endif

            FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform))
            {
                studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;

                #if UNITY_5_0 || UNITY_5_1 // These versions of Unity shipped with FMOD4 profiling enabled consuming our port number.
                UnityEngine.Debug.LogWarning("FMOD Studio: Live Update port in-use by Unity, switching to port 9265");
                advancedSettings.profilePort = 9265;
                #endif
            }

retry:
            result = FMOD.Studio.System.create(out studioSystem);
            CheckInitResult(result, "FMOD.Studio.System.create");

            result = studioSystem.getLowLevelSystem(out lowlevelSystem);
            CheckInitResult(result, "FMOD.Studio.System.getLowLevelSystem");

            result = lowlevelSystem.setOutput(outputType);
            CheckInitResult(result, "FMOD.System.setOutput");

            result = lowlevelSystem.setSoftwareChannels(realChannels);
            CheckInitResult(result, "FMOD.System.setSoftwareChannels");

            result = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0);
            CheckInitResult(result, "FMOD.System.setSoftwareFormat");

            result = lowlevelSystem.setAdvancedSettings(ref advancedSettings);
            CheckInitResult(result, "FMOD.System.setAdvancedSettings");

            result = studioSystem.initialize(virtualChannels, studioInitFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
            if (result != FMOD.RESULT.OK && initResult == FMOD.RESULT.OK)
            {
                initResult = result; // Save this to throw at the end (we'll attempt NO SOUND to shield ourselves from unexpected device failures)
                outputType = FMOD.OUTPUTTYPE.NOSOUND;
                UnityEngine.Debug.LogErrorFormat("FMOD Studio: Studio::System::initialize returned {0}, defaulting to no-sound mode.", result.ToString());

                goto retry;
            }
            CheckInitResult(result, "Studio::System::initialize");

            // Test network functionality triggered during System::update
            if ((studioInitFlags & FMOD.Studio.INITFLAGS.LIVEUPDATE) != 0)
            {
                studioSystem.flushCommands(); // Any error will be returned through Studio.System.update

                result = studioSystem.update();
                if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
                {
                    studioInitFlags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
                    UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update (in-use), restarting with Live Update disabled.");

                    result = studioSystem.release();
                    CheckInitResult(result, "FMOD.Studio.System.Release");

                    goto retry;
                }
            }

            LoadPlugins(fmodSettings);
            LoadBanks(fmodSettings);

            return(initResult);
        }