mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 11:19:58 +01:00
more elegant session source init
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user