more elegant session source init

This commit is contained in:
Bruno
2021-04-29 23:12:46 +02:00
parent 34827ab068
commit 877fb09fa3
2 changed files with 7 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <thread>
#include <chrono>
#include <algorithm>
#include "SessionSource.h"
@@ -163,26 +164,18 @@ void SessionFileSource::init()
}
else {
session_->update(dt_);
if (wait_for_sources_) {
// force update of of all sources
active_ = true;
touch();
// check that every source is ready..
bool ready = true;
for (SourceList::iterator iter = session_->begin(); iter != session_->end(); ++iter)
{
// interrupt if any source is NOT ready
if ( !(*iter)->ready() ){
ready = false;
break;
}
}
// update to draw framebuffer
session_->update(dt_);
// if all sources are ready, done with initialization!
if (ready) {
auto unintitializedsource = std::find_if_not(session_->begin(), session_->end(), Source::isInitialized);
if (unintitializedsource == session_->end()) {
// done init
wait_for_sources_ = false;
initialized_ = true;

View File

@@ -45,7 +45,7 @@ protected:
void init() override;
std::string path_;
std::atomic<bool> wait_for_sources_;
bool wait_for_sources_;
std::future<Session *> sessionLoader_;
};