#include "backend.hpp" #ifdef GLIB_ENABLED #include #endif #include "data.h" #include "thirdparty/CLI11.hpp" std::map UIBackend::backends; std::string UIBackend::get_id() { return ""; } int UIBackend::run(std::vector realArgs, int argc, char **argv) { #ifdef GLIB_ENABLED g_set_application_name("Looper") #endif args = realArgs; playback = new Playback(); CLI::App app{DESCRIPTION}; std::string filename = ""; DBusAPISender sender; app.allow_extras(); double new_speed = 1.0; double new_tempo = 1.0; double new_pitch = 1.0; auto speed_opt = app.add_option("-s,--speed", new_speed, "Set the initial speed of the playback.")->default_val(1.0); auto tempo_opt = app.add_option("-t,--tempo", new_tempo, "Set the initial tempo of the playback.")->default_val(1.0); auto pitch_opt = app.add_option("-p,--pitch", new_pitch, "Set the initial pitch of the playback.")->default_val(1.0); try { app.parse(args); } catch (const CLI::ParseError &e) { throw app.exit(e); } playback->speed = new_speed; playback->tempo = new_tempo; playback->pitch = new_pitch; args = app.remaining(); if (!sender.isOnlyInstance()) { if (args.size() > 0) { sender.playFile(args[0]); } if (!speed_opt->empty()) { sender.setSpeed(new_speed); } if (!tempo_opt->empty()) { sender.setTempo(new_tempo); } if (!pitch_opt->empty()) { sender.setPitch(new_pitch); } throw 0; } else { dbus_api = new DBusAPI(playback); } if (args.size() > 0) { playback->Start(args[0]); } return 0; } void UIBackend::deinit_backends() { for (auto &kv : backends) { delete kv.second; } backends.clear(); } std::string UIBackend::get_name() { return "Unknown frontend"; }