From 7cd1ba8ab23a2ba464659e4ba3024b6c3f339d77 Mon Sep 17 00:00:00 2001 From: jcorporation Date: Tue, 14 Aug 2018 16:32:52 +0200 Subject: [PATCH] Fix: Remove thread support Feat: cleanup api --- htdocs/js/mpd.js | 2 +- src/mpd_client.c | 2 +- src/mympd.c | 14 +------------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index e3f272e..9ef75e2 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -659,7 +659,7 @@ function webSocketConnect() { } switch (obj.type) { - case 'state': + case 'update_state': parseState(obj); break; case 'disconnected': diff --git a/src/mpd_client.c b/src/mpd_client.c index 1dc6dd9..fca955f 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -663,7 +663,7 @@ int mympd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsig audioformat = mpd_status_get_audio_format(status); } - len = json_printf(&out,"{type:state, data:{" + len = json_printf(&out,"{type: update_state, data:{" "state:%d, volume:%d, songPos: %d, elapsedTime: %d, " "totalTime:%d, currentSongId: %d, kbitrate: %d, " "audioFormat: { sampleRate: %d, bits: %d, channels: %d}, " diff --git a/src/mympd.c b/src/mympd.c index 8503376..032d8a9 100644 --- a/src/mympd.c +++ b/src/mympd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "../dist/src/mongoose/mongoose.h" #include "../dist/src/inih/ini.h" @@ -38,7 +37,6 @@ static sig_atomic_t s_signal_received = 0; static struct mg_serve_http_opts s_http_server_opts; char s_redirect[250]; -struct mg_mgr mgr; static void signal_handler(int sig_num) { signal(sig_num, signal_handler); // Reinstantiate signal handler @@ -147,14 +145,8 @@ static int inihandler(void* user, const char* section, const char* name, const c return 1; } -void mympd_poll_loop() { - while (s_signal_received == 0) { - mympd_poll(&mgr, 200); - } -} - int main(int argc, char **argv) { - + struct mg_mgr mgr; struct mg_connection *nc; struct mg_connection *nc_http; struct mg_bind_opts bind_opts; @@ -263,10 +255,6 @@ int main(int argc, char **argv) { if (config.ssl == true) printf("myMPD started on ssl port %s\n", config.sslport); - //Create thread for mpd idle connection - //pthread_t tid; - //pthread_create(&tid, NULL, &mympd_poll_loop, NULL); - //Main loop for http handling while (s_signal_received == 0) { mg_mgr_poll(&mgr, 100);