Beispiel #1
0
        public void Init(string title, IAudioDriver dr)
        {
            comboBoxCustomDevice.Items.AddRange(dr.GetAudioEndpoints().ToArray());
            comboBoxCustomDevice.SelectedItem = dr.GetAudioEndpoint();
            bool border = EDDiscovery.EDDTheme.Instance.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont);

            this.Text = title;
            if (!border)
            {
                label1.Text = title;
            }
        }
Beispiel #2
0
        public static DriverConfiguration Initialise(params string[] assemblyNames)
        {
            foreach (var asmName in assemblyNames)
            {
                AppDomain.CurrentDomain.Load(asmName);
            }

            IMonitorDriver  monitorDriver  = null;
            IWindowDriver   windowDriver   = null;
            IImageDriver    imageDriver    = null;
            IFontDriver     fontDriver     = null;
            IGraphicsDriver graphicsDriver = null;
            IAudioDriver    audioDriver    = null;

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                var jwdriver = assembly.GetCustomAttribute <JankWorksDriver>();

                if (jwdriver != null)
                {
                    var driverInstance = Activator.CreateInstance(jwdriver.DriverType);

                    SetDriverApi(ref monitorDriver, driverInstance);
                    SetDriverApi(ref windowDriver, driverInstance);
                    SetDriverApi(ref imageDriver, driverInstance);
                    SetDriverApi(ref fontDriver, driverInstance);
                    SetDriverApi(ref graphicsDriver, driverInstance);
                    SetDriverApi(ref audioDriver, driverInstance);
                }
            }

            var config = new DriverConfiguration
                         (
                monitorDriver,
                windowDriver,
                imageDriver,
                fontDriver,
                graphicsDriver,
                audioDriver
                         );

            DriverConfiguration.Drivers = config;
            return(config);

            void SetDriverApi <T>(ref T api, object driver)
            {
                if (api == null && driver is T driverApi)
                {
                    api = driverApi;
                }
            }
        }
Beispiel #3
0
        public void Destroy()
        {
            Debug.Assert(_isCreated == true);
            if (_isCreated == false)
            {
                return;
            }

            // Destroy thread
            _shutDown = true;
            _stateChangeEvent.Set();
            _thread.Interrupt();
            _cpu.Stop();
            if (_thread.Join(1000) == false)
            {
                // Failed to wait, so kill
                _thread.Abort();
            }
            while (_thread.IsAlive == true)
            {
                Thread.Sleep(10);
            }
            _thread = null;

#if XMB
            // Destroy XMB
            _xmb.Cleanup();
            _xmb = null;
#else
#endif

            // Destroy all the components
            foreach (IComponentInstance component in _instances)
            {
                if (component != null)
                {
                    component.Cleanup();
                }
            }
            _instances.Clear();
            _audio = null;
            _bios  = null;
            _cpu   = null;
            _io.Clear();
            _video = null;

            _isCreated = false;
            _state     = InstanceState.Idle;
            this.OnStateChanged();
        }
Beispiel #4
0
 public DriverConfiguration
 (
     IMonitorDriver monitorDriver   = null,
     IWindowDriver windowDriver     = null,
     IImageDriver imageDriver       = null,
     IFontDriver fontDriver         = null,
     IGraphicsDriver graphicsDriver = null,
     IAudioDriver audioDriver       = null
 )
 {
     this.monitorApi  = monitorDriver ?? DriverUnitialisedException.driver;
     this.windowApi   = windowDriver ?? DriverUnitialisedException.driver;
     this.imageApi    = imageDriver ?? DriverUnitialisedException.driver;
     this.fontApi     = fontDriver ?? DriverUnitialisedException.driver;
     this.graphicsApi = graphicsDriver ?? DriverUnitialisedException.driver;
     this.audioApi    = audioDriver ?? DriverUnitialisedException.driver;
 }
Beispiel #5
0
        public void Destroy()
        {
            Debug.Assert( _isCreated == true );
            if( _isCreated == false )
                return;

            // Destroy thread
            _shutDown = true;
            _stateChangeEvent.Set();
            _thread.Interrupt();
            _cpu.Stop();
            if( _thread.Join( 1000 ) == false )
            {
                // Failed to wait, so kill
                _thread.Abort();
            }
            while( _thread.IsAlive == true )
                Thread.Sleep( 10 );
            _thread = null;

            #if XMB
            // Destroy XMB
            _xmb.Cleanup();
            _xmb = null;
            #else
            #endif

            // Destroy all the components
            foreach( IComponentInstance component in _instances )
            {
                if( component != null )
                    component.Cleanup();
            }
            _instances.Clear();
            _audio = null;
            _bios = null;
            _cpu = null;
            _io.Clear();
            _video = null;

            _isCreated = false;
            _state = InstanceState.Idle;
            this.OnStateChanged();
        }
Beispiel #6
0
        public bool Create()
        {
            Debug.Assert( _isCreated == false );
            if( _isCreated == true )
                return true;

            _shutDown = false;
            _state = InstanceState.Idle;

            // Try to create all the components
            Debug.Assert( _params.BiosComponent != null );
            Debug.Assert( _params.CpuComponent != null );
            if( _params.AudioComponent != null )
            {
                _audio = _params.AudioComponent.CreateInstance( this, _params[ _params.AudioComponent ] ) as IAudioDriver;
                _instances.Add( ( IComponentInstance )_audio );
            }
            _cpu = _params.CpuComponent.CreateInstance( this, _params[ _params.CpuComponent ] ) as ICpu;
            _instances.Add( ( IComponentInstance )_cpu );
            _bios = _params.BiosComponent.CreateInstance( this, _params[ _params.BiosComponent ] ) as IBios;
            _instances.Add( ( IComponentInstance )_bios );
            foreach( IComponent component in _params.IOComponents )
            {
                IIODriver driver = component.CreateInstance( this, _params[ component ] ) as IIODriver;
                _io.Add( driver );
                _instances.Add( ( IComponentInstance )driver );
            }
            if( _params.InputComponent != null )
            {
                _input = _params.InputComponent.CreateInstance( this, _params[ _params.InputComponent ] ) as IInputDevice;
                _instances.Add( _input );
                _input.WindowHandle = _host.Player.Handle;
            }
            if( _params.UmdComponent != null )
            {
                _umd = _params.UmdComponent.CreateInstance( this, _params[ _params.UmdComponent ] ) as IUmdDevice;
                _instances.Add( _umd );
            }
            if( _params.MemoryStickComponent != null )
            {
                _memoryStick = _params.MemoryStickComponent.CreateInstance( this, _params[ _params.MemoryStickComponent ] ) as IMemoryStickDevice;
                _instances.Add( _memoryStick );
            }
            if( _params.VideoComponent != null )
            {
                _video = _params.VideoComponent.CreateInstance( this, _params[ _params.VideoComponent ] ) as IVideoDriver;
                _video.ControlHandle = _host.Player.ControlHandle;
                _instances.Add( ( IComponentInstance )_video );
            }

            #if XMB
            _xmb = new CrossMediaBar.Manager( this, _host.Player.Handle, _host.Player.ControlHandle );
            #else
            #endif

            // Create thread
            _thread = new Thread( new ThreadStart( this.RuntimeThread ) );
            _thread.Name = "Host runtime thread";
            _thread.IsBackground = true;
            _thread.Start();

            _isCreated = true;

            return true;
        }
Beispiel #7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            WindowElement windowConfig = _config.UI.Window;
            if (windowConfig.X.HasValue && windowConfig.Y.HasValue)
            {
                Rectangle configRect = new Rectangle(windowConfig.X.Value, windowConfig.Y.Value, windowConfig.Width, windowConfig.Height);
                if (Screen.GetWorkingArea(configRect).IntersectsWith(configRect))
                {
                    Left = configRect.X;
                    Top = configRect.Y;
                }
            }

            ClientSize = new Size(windowConfig.Width, windowConfig.Height);

            _coreDriver = new CoreDriver((UIWindow)Overlay, _config);

            _videoDriver = new Direct3D11Driver(this, null);
            _audioDriver = new XAudio2Driver(null);

            _coreDriver.SetDrivers(_videoDriver, _audioDriver);
            _coreDriver.InputAggregator.AddDriver(new RawInputDriver(this));
        }
Beispiel #8
0
 public AudioQueue(IAudioDriver adp)
 {
     ad = adp;
     ad.AudioStoppedEvent += AudioStoppedEvent;
     audioqueue            = new List <AudioSample>();
 }
Beispiel #9
0
 static AL()
 {
     Driver = DriverManager.LoadDriver <IAudioDriver>(GameConfig.SFXDriver, new Version(9, 0, 0));
     Driver.Initialize();
 }
Beispiel #10
0
        public bool Create()
        {
            Debug.Assert(_isCreated == false);
            if (_isCreated == true)
            {
                return(true);
            }

            _shutDown = false;
            _state    = InstanceState.Idle;

            // Try to create all the components
            Debug.Assert(_params.BiosComponent != null);
            Debug.Assert(_params.CpuComponent != null);
            if (_params.AudioComponent != null)
            {
                _audio = _params.AudioComponent.CreateInstance(this, _params[_params.AudioComponent]) as IAudioDriver;
                _instances.Add(( IComponentInstance )_audio);
            }
            _cpu = _params.CpuComponent.CreateInstance(this, _params[_params.CpuComponent]) as ICpu;
            _instances.Add(( IComponentInstance )_cpu);
            _bios = _params.BiosComponent.CreateInstance(this, _params[_params.BiosComponent]) as IBios;
            _instances.Add(( IComponentInstance )_bios);
            foreach (IComponent component in _params.IOComponents)
            {
                IIODriver driver = component.CreateInstance(this, _params[component]) as IIODriver;
                _io.Add(driver);
                _instances.Add(( IComponentInstance )driver);
            }
            if (_params.InputComponent != null)
            {
                _input = _params.InputComponent.CreateInstance(this, _params[_params.InputComponent]) as IInputDevice;
                _instances.Add(_input);
                //_input.WindowHandle = _host.Player.Handle;
            }
            if (_params.UmdComponent != null)
            {
                _umd = _params.UmdComponent.CreateInstance(this, _params[_params.UmdComponent]) as IUmdDevice;
                _instances.Add(_umd);
            }
            if (_params.MemoryStickComponent != null)
            {
                _memoryStick = _params.MemoryStickComponent.CreateInstance(this, _params[_params.MemoryStickComponent]) as IMemoryStickDevice;
                _instances.Add(_memoryStick);
            }
            if (_params.VideoComponent != null)
            {
                _video = _params.VideoComponent.CreateInstance(this, _params[_params.VideoComponent]) as IVideoDriver;
                //_video.ControlHandle = _host.Player.ControlHandle;
                _instances.Add(( IComponentInstance )_video);
            }

            // Create thread
            _thread              = new Thread(new ThreadStart(this.RuntimeThread));
            _thread.Name         = "Host runtime thread";
            _thread.IsBackground = true;
            _thread.Start();

            _isCreated = true;

            return(true);
        }
Beispiel #11
0
 public ConcretePlaySoundCommand(PlaySoundCommand command, IZoneServer zoneServer, IAudioDriver audioDriver)
     : base(command)
 {
     _playSoundCommand = command;
     _audioDriver      = audioDriver;
 }
Beispiel #12
0
        public void SetDrivers(IVideoDriver videoDriver, IAudioDriver audioDriver)
        {
            AssertUndisposed();

            bool wasRunning = _isRunning;

            if (wasRunning) { Stop(); }
            _videoDriver = videoDriver;
            _audioDriver = audioDriver;
            if (wasRunning) { Start(); }
        }
Beispiel #13
0
 public override void Stop()
 {
     if( _driver != null )
         _driver.ReleaseAllChannels();
     _driver = null;
 }
Beispiel #14
0
 public override void Start()
 {
     _driver = _kernel.Emulator.Audio;
 }