mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
add parameter initInBackground to force init in background thread (but still uses a lot of CPU if game is launched while not finished), and parameter initMetaDb to initialize or not the meta db that takes a lot of time
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
8532aa196e
commit
f7b831f0ab
@ -57,7 +57,7 @@
|
||||
|
||||
#define REMOVE_TEST_FUNKEY
|
||||
#define FUNKEY_ALL_POLLEVENT_DELAY 30 //ms
|
||||
#define PERIOD_FORCE_REFRESH 1000 //ms
|
||||
//#define PERIOD_FORCE_REFRESH 1000 //ms
|
||||
|
||||
#define FPS 30 // TODO: set in conf file
|
||||
|
||||
@ -72,6 +72,7 @@
|
||||
RetroFE::RetroFE( Configuration &c )
|
||||
: initialized(false)
|
||||
, initializeError(false)
|
||||
, initMetaDb(true)
|
||||
, initializeThread(NULL)
|
||||
, config_(c)
|
||||
, db_(NULL)
|
||||
@ -152,6 +153,7 @@ int RetroFE::initialize( void *context )
|
||||
instance->initializeError = true;
|
||||
return -1;
|
||||
}
|
||||
Logger::write( Logger::ZONE_INFO, "RetroFE", "Initialized user controls" );
|
||||
|
||||
instance->db_ = new DB( Utils::combinePath( Configuration::absolutePath, "meta.db" ) );
|
||||
|
||||
@ -161,15 +163,21 @@ int RetroFE::initialize( void *context )
|
||||
instance->initializeError = true;
|
||||
return -1;
|
||||
}
|
||||
Logger::write( Logger::ZONE_INFO, "RetroFE", "Initialized database" );
|
||||
|
||||
instance->metadb_ = new MetadataDatabase( *(instance->db_), instance->config_ );
|
||||
|
||||
|
||||
if(instance->initMetaDb){
|
||||
Logger::write( Logger::ZONE_INFO, "RetroFE", "Initializing meta database..." );
|
||||
if ( !instance->metadb_->initialize( ) )
|
||||
{
|
||||
Logger::write( Logger::ZONE_ERROR, "RetroFE", "Could not initialize meta database" );
|
||||
instance->initializeError = true;
|
||||
return -1;
|
||||
}
|
||||
Logger::write( Logger::ZONE_INFO, "RetroFE", "Initialized meta database" );
|
||||
}
|
||||
|
||||
instance->initialized = true;
|
||||
return 0;
|
||||
@ -457,7 +465,10 @@ void RetroFE::run( )
|
||||
VideoFactory::createVideo( ); // pre-initialize the gstreamer engine
|
||||
Video::setEnabled( videoEnable );
|
||||
|
||||
//initializeThread = SDL_CreateThread( initialize, "RetroFEInit", (void *)this );
|
||||
// Init thread
|
||||
bool initMetaDbtmp;
|
||||
config_.getProperty( "initMetaDb", initMetaDbtmp );
|
||||
initMetaDb = initMetaDbtmp;
|
||||
initializeThread = SDL_CreateThread( initialize, (void *)this );
|
||||
|
||||
if ( !initializeThread )
|
||||
@ -469,6 +480,8 @@ void RetroFE::run( )
|
||||
int attractModeTime = 0;
|
||||
std::string firstCollection = "Main";
|
||||
bool running = true;
|
||||
bool initInBackground = false;
|
||||
config_.getProperty( "initInBackground", initInBackground );
|
||||
RETROFE_STATE state = RETROFE_NEW;
|
||||
|
||||
config_.getProperty( "attractModeTime", attractModeTime );
|
||||
@ -548,9 +561,13 @@ void RetroFE::run( )
|
||||
}
|
||||
|
||||
// Handle end of splash mode
|
||||
if ( (initialized || initializeError) && splashMode && (exitSplashMode || (currentPage_->getMinShowTime( ) <= (currentTime_ - preloadTime) && !(currentPage_->isPlaying( )))) )
|
||||
if ( ( (initialized || initializeError) && splashMode && (exitSplashMode || (currentPage_->getMinShowTime( ) <= (currentTime_ - preloadTime) && !(currentPage_->isPlaying( )))) )
|
||||
|| (initInBackground && splashMode) )
|
||||
{
|
||||
if(!initInBackground){
|
||||
SDL_WaitThread( initializeThread, &initializeStatus );
|
||||
printf("SDL_WaitThread finisheds\n");
|
||||
}
|
||||
|
||||
if ( initializeError )
|
||||
{
|
||||
@ -1097,7 +1114,10 @@ void RetroFE::run( )
|
||||
// ------- Real render here -------
|
||||
if(must_render){
|
||||
render( );
|
||||
#ifdef PERIOD_FORCE_REFRESH
|
||||
ticks_last_refresh = SDL_GetTicks();
|
||||
#endif //PERIOD_FORCE_REFRESH
|
||||
akes a lot of time
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ public:
|
||||
private:
|
||||
volatile bool initialized;
|
||||
volatile bool initializeError;
|
||||
volatile bool initMetaDb;
|
||||
SDL_Thread *initializeThread;
|
||||
static int initialize( void *context );
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user