diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index b72ba3a..f445065 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -143,6 +143,10 @@ void Application::addFboSource(FboSource & fboSource){ _mediaServer.addFboSource(fboSource); } +void Application::addFboSource(FboSource * fboSource){ + _mediaServer.addFboSource(fboSource); +} + void Application::setState(ApplicationBaseState * st){ _state = st; } diff --git a/src/Application/Application.h b/src/Application/Application.h index 7d74aba..31a250e 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -52,6 +52,7 @@ class Application : public KeyListener { // Every state should have it's own GUI layer void addFboSource(FboSource & fboSource); + void addFboSource(FboSource * fboSource); bool loadXmlSettings(string fileName); bool isShiftKeyDown(); diff --git a/src/MediaServer/MediaServer.cpp b/src/MediaServer/MediaServer.cpp index b0f300d..deaf3ff 100644 --- a/src/MediaServer/MediaServer.cpp +++ b/src/MediaServer/MediaServer.cpp @@ -315,20 +315,27 @@ string MediaServer::getDefaultMediaDir(int sourceType){ } void MediaServer::addFboSource(ofx::piMapper::FboSource & fboSource){ - ofLogNotice("MediaServer") << "Attempting to add FBO source with name " << fboSource.getName(); + addFboSource(&fboSource); +} + +void MediaServer::addFboSource(FboSource * fboSource){ + ofLogNotice("MediaServer") << "Attempting to add FBO source with name " << fboSource->getName(); + // FBO source has to be with unique name - for(int i = 0; i < fboSources.size(); i++){ - if(fboSources[i]->getName() == fboSource.getName()){ + for(int i = 0; i < fboSources.size(); ++i){ + if(fboSources[i]->getName() == fboSource->getName()){ ofLogWarning("MediaServer") << "Attempt to add FBO source with duplicate name"; ofExit(EXIT_FAILURE); // Here we definitely need to fail to avoid confusion + std::exit(EXIT_FAILURE); // In case the openFrameworks function fails } } + ofLogNotice("MediaServer") << "Source new, adding"; - fboSources.push_back(&fboSource); + fboSources.push_back(fboSource); // It is important to run the setup of the FBO // source from outside as we can see here. - fboSource.setup(); + fboSource->setup(); } BaseSource * MediaServer::loadFboSource(string & fboSourceName){ diff --git a/src/MediaServer/MediaServer.h b/src/MediaServer/MediaServer.h index b5e672d..3d7e164 100644 --- a/src/MediaServer/MediaServer.h +++ b/src/MediaServer/MediaServer.h @@ -62,6 +62,8 @@ class MediaServer { // Do things with FBO sources void addFboSource(FboSource & fboSource); // could be called also as register FBO source + void addFboSource(FboSource * fboSource); + BaseSource * loadFboSource(string & fboSourceName); void unloadFboSource(string & fboSourceName); diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 7961dac..e313d7a 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -14,6 +14,10 @@ void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){ _application.addFboSource(fboSource); } +void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource * fboSource){ + _application.addFboSource(fboSource); +} + bool ofxPiMapper::loadXmlSettings(string fileName){ return _application.loadXmlSettings(fileName); } \ No newline at end of file diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 358df78..a593446 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -26,6 +26,7 @@ class ofxPiMapper { void draw(); void registerFboSource(ofx::piMapper::FboSource & fboSource); + void registerFboSource(ofx::piMapper::FboSource * fboSource); bool loadXmlSettings(string fileName); private: