示例#1
0
        //--------------------//

        #region Dispose
        protected override void OnDispose()
        {
            Log.Info("Disposing engine\nLast framerate: " + Performance.Fps);

            // Dispose scenes and views
            ExtraRender = null;
            foreach (var view in Views)
            {
                view.Scene.Dispose();
            }
            base.OnDispose();

            // Shutdown music
            Music?.Dispose();

            // Dispose cached assets
            Cache?.Dispose();

            // Dispose default meshes
            SimpleSphere?.Dispose();
            SimpleBox?.Dispose();

            // Dispose Direct3D device
            BackBuffer?.Dispose();
            Device?.Dispose();

            // Dispose DirectSound objects
            //_listener?.Dispose();
            AudioDevice?.Dispose();

            _direct3D?.Dispose();

            // Dispose debug window
            _debugForm?.Dispose();
        }
示例#2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components.
                    for (int i = 0; i < _components.Count; i += 1)
                    {
                        IDisposable disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (_content != null)
                    {
                        _content.Dispose();
                        _content = null;
                    }


                    if (_graphicsDeviceService != null)
                    {
                        // FIXME: Does XNA4 require the GDM to be disposable? -flibit
                        (_graphicsDeviceService as IDisposable).Dispose();
                        _graphicsDeviceService = null;
                    }

                    AudioDevice.Dispose();

                    if (Platform != null)
                    {
                        Platform.Activated   -= OnActivated;
                        Platform.Deactivated -= OnDeactivated;
                        _services.RemoveService(typeof(GamePlatform));
                        Platform.Dispose();
                        Platform = null;
                    }

                    ContentTypeReaderManager.ClearTypeCreators();
                }

                AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

                _isDisposed = true;
                Instance    = null;
            }
        }
示例#3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    // Dispose loaded game components.
                    for (int i = 0; i < _components.Count; i += 1)
                    {
                        IDisposable disposable = _components[i] as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    _components = null;

                    if (_content != null)
                    {
                        _content.Dispose();
                        _content = null;
                    }


                    if (_graphicsDeviceService != null)
                    {
                        // FIXME: Does XNA4 require the GDM to be disposable? -flibit
                        (_graphicsDeviceService as IDisposable).Dispose();
                        _graphicsDeviceService = null;
                    }

                    AudioDevice.Dispose();

                    if (Window != null)
                    {
                        FNAPlatform.DisposeWindow(Window);
                        Window = null;
                    }
                    Mouse.WindowHandle = IntPtr.Zero;

                    ContentTypeReaderManager.ClearTypeCreators();
                }

                AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

                _isDisposed = true;
            }
        }
示例#4
0
        private void UnixPlayThread(object state)
        {
            if (_unixPlayStopEvent.WaitOne(0))
            {
                return;
            }
            Stream      stream = null;
            AudioDevice dev    = null;

            try
            {
                lock (s_playSync)
                {
                    dev          = AudioDevice.CreateAlsaDevice(_latency);
                    stream       = ReadFile((string)state);
                    _unixWavData = new WavData(_logger, stream, _unixPlayStopEvent);
                }
                _unixWavData.Setup(dev);
                _unixWavData.Play(dev);
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                _logger.LogError(Message.SoundPlayError, ex, (string)state);
            }
            finally
            {
                if (dev != null)
                {
                    dev.Dispose();
                }
                if (stream != null)
                {
                    stream.Close();
                }
                if (_unixWavData == null || !_unixWavData.IsStopped)
                {
                    PlayingStopped.RaiseEvent(this);
                }
            }
        }
 public void ShutDown()
 {
     foreach (var s in streamSlots.Keys)
     {
         s.Dispose();
     }
     streamSlots.Clear();
     foreach (var svs in freeVoices)
     {
         svs.Dispose();
     }
     freeVoices.Clear();
     foreach (var svs in usedVoices)
     {
         svs.Dispose();
     }
     usedVoices.Clear();
     masteringVoice.Dispose();
     AudioDevice.Dispose();
 }
示例#6
0
文件: Engine.cs 项目: K0bin/DotGame
 protected virtual void Dispose(bool isDisposing)
 {
     if (ShaderManager != null)
     {
         ShaderManager.Dispose();
     }
     if (RenderStatePool != null)
     {
         RenderStatePool.Dispose();
     }
     if (GraphicsDevice != null)
     {
         GraphicsDevice.Dispose();
     }
     if (AudioDevice != null)
     {
         AudioDevice.Dispose();
     }
     if (onStart != null)
     {
         onStart.Dispose();
     }
 }
 public static void Dispose()
 {
     device.Dispose();
     AudioManager.Dispose();
 }