Beispiel #1
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 #2
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 #3
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 #4
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);
        }