29 lines
848 B
C++
29 lines
848 B
C++
|
#include "daemon_backend.hpp"
|
||
|
#include "log.hpp"
|
||
|
#include <thread>
|
||
|
#include <chrono>
|
||
|
using namespace std::literals::chrono_literals;
|
||
|
std::string DaemonGlueBackend::get_id() {
|
||
|
return "daemon";
|
||
|
}
|
||
|
std::string DaemonGlueBackend::get_name() {
|
||
|
return "Daemon Backend";
|
||
|
}
|
||
|
bool DaemonGlueBackend::allow_multi_instance() {
|
||
|
return false;
|
||
|
}
|
||
|
int DaemonGlueBackend::run(std::vector<std::string> realArgs, int argc, char **argv) {
|
||
|
parse_args(realArgs, argc, argv);
|
||
|
playback = Playback::Create(nullptr, true);
|
||
|
if (playback == nullptr) {
|
||
|
ERROR.writeln("Cannot start daemon with existing instance running.");
|
||
|
return 1;
|
||
|
}
|
||
|
setup_playback_args();
|
||
|
dbus_api = DBusAPI::Create(playback, true);
|
||
|
exit_flag.store(false);
|
||
|
while (!exit_flag.load()) {
|
||
|
std::this_thread::sleep_for(100ms);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|