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