author | František Kučera <franta-hg@frantovo.cz> |
Fri, 18 Dec 2020 23:28:16 +0100 | |
branch | v_0 |
changeset 3 | e238528eb19c |
parent 2 | f34476ab597f |
child 5 | ef8f4023e32e |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* DJM-Fix |
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
|
4 |
* |
|
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation, version 3 of the License. |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
||
1 | 18 |
#include <memory> |
19 |
#include <iostream> |
|
2
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
20 |
#include <chrono> |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
21 |
#include <thread> |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
22 |
#include <csignal> |
1 | 23 |
|
24 |
#include "DJMFix.h" |
|
2
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
25 |
#include "AlsaBridge.h" |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
26 |
|
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
27 |
volatile static bool run = true; |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
28 |
|
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
29 |
void interrupt(int signal) { |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
30 |
run = false; |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
31 |
std::cerr << "interrupt()" << std::endl; // TODO: do not mess STDIO |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
32 |
} |
1 | 33 |
|
0 | 34 |
int main(int argc, char**argv) { |
2
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
35 |
signal(SIGINT, interrupt); |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
36 |
std::unique_ptr<djmfix::DJMFix> djmFix(djmfix::create()); |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
37 |
std::unique_ptr<djmfix::alsa::AlsaBridge> alsaBridge(djmfix::alsa::create(djmFix.get())); |
1 | 38 |
|
2
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
39 |
alsaBridge->start(); |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
40 |
while (run) std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
f34476ab597f
background thread + AlsaBridge skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
41 |
alsaBridge->stop(); |
1 | 42 |
|
0 | 43 |
return 0; |
44 |
} |