2013-12-08 21:44:43 +00:00
|
|
|
/*
|
|
|
|
* Author: Harry van Haaren 2013
|
|
|
|
* harryhaaren@gmail.com
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-04-20 11:37:36 +01:00
|
|
|
|
2013-09-11 12:57:31 +01:00
|
|
|
#include "config.hxx"
|
2013-11-14 17:32:51 +00:00
|
|
|
#include "version.hxx"
|
2013-04-20 11:37:36 +01:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <unistd.h>
|
2013-09-21 00:52:29 +01:00
|
|
|
#include <signal.h>
|
2013-04-20 11:37:36 +01:00
|
|
|
|
|
|
|
#include <jack/ringbuffer.h>
|
|
|
|
|
2013-04-20 11:50:30 +01:00
|
|
|
#include "gui.hxx"
|
2013-04-20 11:37:36 +01:00
|
|
|
#include "jack.hxx"
|
2013-04-20 11:54:16 +01:00
|
|
|
#include "event.hxx"
|
2013-04-20 12:20:46 +01:00
|
|
|
#include "denormals.hxx"
|
2013-04-20 11:37:36 +01:00
|
|
|
|
2013-09-21 00:52:29 +01:00
|
|
|
int signalHanlderInt = 0;
|
|
|
|
|
2014-08-10 22:20:57 +01:00
|
|
|
EventBase* processDspMem = 0;
|
|
|
|
EventBase* processGuiMem = 0;
|
2013-04-20 11:37:36 +01:00
|
|
|
|
|
|
|
jack_ringbuffer_t* rbToDsp = 0;
|
|
|
|
jack_ringbuffer_t* rbToGui = 0;
|
|
|
|
|
2013-05-16 13:38:46 +01:00
|
|
|
// global static pointers, for access from EventHandlerGui and EventHandlerDsp
|
|
|
|
Gui * gui = 0;
|
2013-04-20 11:37:36 +01:00
|
|
|
Jack* jack = 0;
|
|
|
|
|
2013-09-11 12:57:31 +01:00
|
|
|
|
2013-09-21 00:52:29 +01:00
|
|
|
void signalHanlder(int signum)
|
|
|
|
{
|
|
|
|
signalHanlderInt = signum;
|
|
|
|
}
|
|
|
|
|
2013-11-25 15:50:55 +00:00
|
|
|
static void gui_static_loadSession_cb(void* inst)
|
|
|
|
{
|
|
|
|
char* tmp = (char*) inst;
|
|
|
|
int sess = gui->getDiskReader()->readSession( tmp );
|
|
|
|
if ( sess != LUPPP_RETURN_OK )
|
|
|
|
LUPPP_ERROR( "Error loading session" );
|
|
|
|
}
|
|
|
|
|
2014-08-08 23:12:36 +01:00
|
|
|
|
|
|
|
|
2013-09-11 12:57:31 +01:00
|
|
|
int main(int argc, char** argv)
|
2013-04-20 11:37:36 +01:00
|
|
|
{
|
2014-02-23 18:16:53 +00:00
|
|
|
LUPPP_NOTE("Git: %s", GIT_VERSION );
|
2013-11-14 17:32:51 +00:00
|
|
|
|
2014-08-10 22:20:57 +01:00
|
|
|
bool runTests = false;
|
2013-11-25 15:50:55 +00:00
|
|
|
if ( runTests ){} // remove unused warning if not built with BUILD_TESTS
|
2013-09-18 11:46:25 +01:00
|
|
|
|
2013-09-17 10:17:33 +01:00
|
|
|
for(int i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if ( strcmp(argv[i], "-test" ) == 0 ) {
|
|
|
|
runTests = true;
|
2013-11-25 15:50:55 +00:00
|
|
|
}
|
2013-12-01 17:00:23 +00:00
|
|
|
else if ( i != 0 ) // don't try load with the program name!
|
2013-11-25 15:50:55 +00:00
|
|
|
{
|
|
|
|
// assume filename, try load it
|
|
|
|
Fl::repeat_timeout( 1 / 30.f, &gui_static_loadSession_cb, argv[i] );
|
2013-09-17 10:17:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-20 12:20:46 +01:00
|
|
|
// setup the environment
|
|
|
|
AVOIDDENORMALS();
|
2013-09-21 00:52:29 +01:00
|
|
|
signal(SIGINT , signalHanlder);
|
|
|
|
signal(SIGTERM, signalHanlder);
|
2013-04-20 12:20:46 +01:00
|
|
|
|
2013-04-20 11:54:16 +01:00
|
|
|
// allocate data to read from
|
2014-08-10 22:20:57 +01:00
|
|
|
processDspMem = (EventBase*)malloc( sizeof(EventBase) );
|
|
|
|
processGuiMem = (EventBase*)malloc( sizeof(EventBase) );
|
2013-04-20 11:54:16 +01:00
|
|
|
|
2013-05-16 13:38:46 +01:00
|
|
|
rbToDsp = jack_ringbuffer_create( 5000 * sizeof(EventBase));
|
|
|
|
rbToGui = jack_ringbuffer_create( 5000 * sizeof(EventBase));
|
2013-04-20 11:54:16 +01:00
|
|
|
|
2014-08-08 13:54:18 +01:00
|
|
|
|
2013-09-11 12:57:31 +01:00
|
|
|
#ifdef BUILD_TESTS
|
2013-12-04 13:50:08 +00:00
|
|
|
LUPPP_NOTE("Built with BUILD_TESTS enabled");
|
2013-09-17 10:17:33 +01:00
|
|
|
if ( runTests )
|
|
|
|
{
|
2013-09-17 12:07:25 +01:00
|
|
|
// counts failures
|
|
|
|
int testResult = 0;
|
|
|
|
|
2013-10-03 10:17:23 +01:00
|
|
|
// setup the testing Gui / JACK: Jack first, then GUI
|
2013-12-09 01:03:00 +00:00
|
|
|
gui = new Gui( argv[0] );
|
2014-08-10 22:20:57 +01:00
|
|
|
Jack::setup("LupppTEST");
|
2013-09-17 11:00:12 +01:00
|
|
|
|
2013-09-17 10:17:33 +01:00
|
|
|
// test offline functionality
|
2013-09-23 12:21:33 +01:00
|
|
|
testResult += gui->getDiskReader()->runTests();
|
2013-09-17 12:07:25 +01:00
|
|
|
testResult += gui->getDiskWriter()->runTests();
|
2013-09-17 11:00:12 +01:00
|
|
|
|
2013-09-17 10:17:33 +01:00
|
|
|
// test realtime functionality
|
2013-09-17 12:07:25 +01:00
|
|
|
testResult += jack->getGridLogic()->runTests();
|
2013-09-17 10:17:33 +01:00
|
|
|
|
2013-11-09 20:58:48 +00:00
|
|
|
jack->quit();
|
|
|
|
|
2013-09-17 11:00:12 +01:00
|
|
|
delete gui;
|
|
|
|
delete jack;
|
2013-11-09 20:58:48 +00:00
|
|
|
jack = 0;
|
2013-09-17 11:00:12 +01:00
|
|
|
|
2013-11-09 20:58:48 +00:00
|
|
|
// running tests == quitting after testing finishes
|
|
|
|
return testResult;
|
2013-09-17 10:17:33 +01:00
|
|
|
}
|
2013-11-09 20:58:48 +00:00
|
|
|
|
2014-08-08 13:54:18 +01:00
|
|
|
#endif
|
2013-09-17 11:00:12 +01:00
|
|
|
|
2014-08-08 23:12:36 +01:00
|
|
|
|
2013-12-04 13:50:08 +00:00
|
|
|
// Create a GUI, check for NSM integration
|
|
|
|
gui = new Gui( argv[0] );
|
2013-10-03 10:17:23 +01:00
|
|
|
|
2013-11-08 00:18:48 +00:00
|
|
|
if ( gui->getNsm() )
|
|
|
|
{
|
|
|
|
// the NSM OSC Open message will trigger Jack initialization: necessary
|
|
|
|
// to use the right name to create the JACK client.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Jack::setup("Luppp");
|
|
|
|
jack->activate();
|
|
|
|
}
|
2013-10-03 10:17:23 +01:00
|
|
|
|
2013-05-16 13:38:46 +01:00
|
|
|
gui->show();
|
2013-09-17 12:07:25 +01:00
|
|
|
|
2014-08-08 13:54:18 +01:00
|
|
|
|
2013-09-17 12:07:25 +01:00
|
|
|
return 0;
|
2013-04-20 11:37:36 +01:00
|
|
|
}
|
2013-09-11 12:57:31 +01:00
|
|
|
|