81 |
81 |
82 int main(int argc, char**argv) { |
82 int main(int argc, char**argv) { |
83 using L = djmfix::logging::Level; |
83 using L = djmfix::logging::Level; |
84 std::unique_ptr<djmfix::logging::Logger> logger(djmfix::logging::create(std::cerr, L::INFO)); |
84 std::unique_ptr<djmfix::logging::Logger> logger(djmfix::logging::create(std::cerr, L::INFO)); |
85 try { |
85 try { |
86 logger->log(L::INFO, "djm-fix started"); |
86 logger->log(L::INFO, "DJM-Fix started."); |
87 std::string cardNamePattern = argc == 2 ? argv[1] : "Pioneer DJ.*"; |
87 std::string cardNamePattern = argc == 2 ? argv[1] : "Pioneer DJ.*"; |
88 |
88 |
89 signal(SIGINT, interrupt); |
89 signal(SIGINT, interrupt); |
90 std::unique_ptr<djmfix::DJMFix> djmFix(djmfix::create(logger.get())); |
90 std::unique_ptr<djmfix::DJMFix> djmFix(djmfix::create(logger.get())); |
91 std::unique_ptr<djmfix::alsa::AlsaBridge> alsaBridge(djmfix::alsa::create(djmFix.get(), cardNamePattern, logger.get())); |
91 std::unique_ptr<djmfix::alsa::AlsaBridge> alsaBridge(djmfix::alsa::create(djmFix.get(), cardNamePattern, logger.get())); |
92 |
92 |
93 alsaBridge->start(); |
93 alsaBridge->start(); |
94 while (run) std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
94 while (run) std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
95 |
95 |
96 std::cerr << std::endl; |
96 std::cerr << std::endl; |
97 logger->log(L::INFO, "djm-fix stopping"); |
97 logger->log(L::INFO, "DJM-Fix stopping."); |
98 |
98 |
99 alsaBridge->stop(); |
99 alsaBridge->stop(); |
100 |
100 |
101 return 0; |
101 return 0; |
102 } catch (const std::exception& e) { |
102 } catch (const std::exception& e) { |