-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
151 lines (122 loc) · 2.96 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* @file main.cpp
* @brief Brief description of file.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <stdint.h>
#include <signal.h>
#include <string>
#include <iostream>
#include <getopt.h>
#include <iostream>
#include "channel.h"
#include "ctrl.h"
#include "exception.h"
#include "tokeniser.h"
#include "tokens.h"
#include "plugins.h"
#include "monitor.h"
#include "diamond.h"
#include "process.h"
using namespace std;
// command line options
struct option opts[]={
{"nogui",no_argument,NULL,'n'},
{NULL,0,NULL,0}
};
extern void parseConfig(const char *filename);
/*
* Initialisation
*
*/
void poll(){
diamond.poll();
}
void noguiloop(){
while(1){
usleep(100000);
static MonitorData mdat;
Process::pollMonRing(&mdat);
poll();
}
}
void guiloop(){
struct sigaction sa;
sa.sa_handler = SIG_IGN;
sigemptyset(&sa.sa_mask);
sa.sa_flags=0;
sigaction(SIGQUIT,&sa,NULL);
sigaction(SIGINT,&sa,NULL);
// start the non-blocking monitor thread.
MonitorThread thread;
InputManager input;
// run the screens until we complete, when the thread will die.
input.flow();
}
void usage(){
cerr << "usage:\n"
<< "jackmix [-n] [configfile]\n";
}
int main(int argc,char *argv[]){
bool nogui=false;
extern float *zeroBuf;
zeroBuf = new float[BUFSIZE];
for(int i=0;i<BUFSIZE;i++)zeroBuf[i]=0;
try {
const char *filename="config";
for(;;){
int optind=0;
char c = getopt_long(argc,argv,"n",opts,&optind);
if(c<0)break;
switch(c){
case 'n':
nogui=true;
break;
default:
usage();
throw _("incorrect usage");
}
}
if(optind<argc)
filename = argv[optind];
// initialise data structures
Process::init();
// initialise comms
diamond.init();
// initialise Jack
Process::initJack();
// load LADSPA plugins
PluginMgr::loadFilesIn("/usr/lib/ladspa",true);
//PluginMgr::loadFilesIn("./testpl");
// parse the config
parseConfig(filename);
Ctrl::checkAllCtrlsForSource();
Channel::resolveAllChannelChains();
} catch (const char *s){
printf("Redundant error : %s\n",s);
exit(1);
} catch (string s){
cout << "Fatal error: " << s << endl;
exit(1);
}
// start the processing thread
Process::parsedAndReady=true;
try {
if(nogui)
noguiloop();
else {
// start the non-blocking monitor thread
guiloop();
}
} catch(string s){
// PluginMgr::close();
Process::shutdown();
cout << "Fatal error: " << s << endl;
}
Value::dump();
Process::shutdown();
}