Added libmpdclient and basic fifo sync code
This commit is contained in:
20
src/main.cpp
20
src/main.cpp
@ -8,6 +8,8 @@
|
||||
// For sleep
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
// MPD client
|
||||
#include "mpd/client.h"
|
||||
|
||||
// Local files
|
||||
#include "utility/bitmap.hpp"
|
||||
@ -50,6 +52,8 @@ const size_t width = 10;
|
||||
const size_t height = BOTTOM_SKIP + KB_RESOLUTION + TOP_SKIP;
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
@ -90,15 +94,26 @@ int main(int argc, char *argv[]) {
|
||||
std::chrono::steady_clock,
|
||||
std::chrono::nanoseconds
|
||||
> t = std::chrono::steady_clock::now();
|
||||
//t += std::chrono::milliseconds(30);
|
||||
//this_thread::sleep_until(t);
|
||||
|
||||
std::chrono::time_point<
|
||||
std::chrono::steady_clock,
|
||||
std::chrono::nanoseconds
|
||||
> last_fifo_sync = std::chrono::steady_clock::now();
|
||||
|
||||
struct mpd_connection *conn = mpd_connection_new(NULL, 0, 0);
|
||||
|
||||
while (1) {
|
||||
|
||||
if (Dox.is_connected()) {
|
||||
if (std::chrono::steady_clock::now() > t + std::chrono::milliseconds(30)) {
|
||||
if (Dox.get_animation_mode() == 0x02) {
|
||||
if (std::chrono::steady_clock::now() > last_fifo_sync + std::chrono::seconds(10)) {
|
||||
mpd_run_disable_output(conn, 1);
|
||||
mpd_run_enable_output(conn, 1);
|
||||
last_fifo_sync = std::chrono::steady_clock::now();
|
||||
spdlog::info("Synchronized fifo");
|
||||
}
|
||||
|
||||
buf.update();
|
||||
fft.update(buf);
|
||||
|
||||
@ -140,5 +155,6 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
mpd_connection_free(conn);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user