diff -r 4d95b089457d -r 5b351628a377 djm-fix.cpp --- a/djm-fix.cpp Mon Jan 04 00:15:56 2021 +0100 +++ b/djm-fix.cpp Mon Jan 04 13:38:08 2021 +0100 @@ -70,22 +70,29 @@ * make # we can skip this step, it will be compiled on the first run * * Run: - * make run + * make run # in most cases + * build/djm-fix 'Pioneer DJ.*' # or provide custom name pattern (regular expression) to select the proper card * * Stop: * press Ctrl+C + * + * Look for updates in the Mercurial repositories and at . */ int main(int argc, char**argv) { - std::string deviceName = argc == 2 ? argv[1] : "hw:1"; // FIXME: parse CLI options + automatic device search + try { + std::string cardNamePattern = argc == 2 ? argv[1] : "Pioneer DJ.*"; - signal(SIGINT, interrupt); - std::unique_ptr djmFix(djmfix::create()); - std::unique_ptr alsaBridge(djmfix::alsa::create(djmFix.get(), deviceName)); + signal(SIGINT, interrupt); + std::unique_ptr djmFix(djmfix::create()); + std::unique_ptr alsaBridge(djmfix::alsa::create(djmFix.get(), cardNamePattern)); - alsaBridge->start(); - while (run) std::this_thread::sleep_for(std::chrono::milliseconds(100)); - alsaBridge->stop(); + alsaBridge->start(); + while (run) std::this_thread::sleep_for(std::chrono::milliseconds(100)); + alsaBridge->stop(); - return 0; + return 0; + } catch (const std::exception& e) { + std::cerr << "ERROR: " << e.what() << std::endl; // TODO: do not mess STDIO + } }