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
     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 
    18 #include <memory>
    19 #include <iostream>
    20 #include <chrono>
    21 #include <thread>
    22 #include <csignal>
    23 
    24 #include "DJMFix.h"
    25 #include "AlsaBridge.h"
    26 
    27 volatile static bool run = true;
    28 
    29 void interrupt(int signal) {
    30 	run = false;
    31 	std::cerr << "interrupt()" << std::endl; // TODO: do not mess STDIO
    32 }
    33 
    34 int main(int argc, char**argv) {
    35 	signal(SIGINT, interrupt);
    36 	std::unique_ptr<djmfix::DJMFix> djmFix(djmfix::create());
    37 	std::unique_ptr<djmfix::alsa::AlsaBridge> alsaBridge(djmfix::alsa::create(djmFix.get()));
    38 
    39 	alsaBridge->start();
    40 	while (run) std::this_thread::sleep_for(std::chrono::milliseconds(100));
    41 	alsaBridge->stop();
    42 
    43 	return 0;
    44 }