--- 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 <https://blog.frantovo.cz/c/387/>.
*/
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> djmFix(djmfix::create());
- std::unique_ptr<djmfix::alsa::AlsaBridge> alsaBridge(djmfix::alsa::create(djmFix.get(), deviceName));
+ signal(SIGINT, interrupt);
+ std::unique_ptr<djmfix::DJMFix> djmFix(djmfix::create());
+ std::unique_ptr<djmfix::alsa::AlsaBridge> 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
+ }
}