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

View File

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