1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-27 03:10:26 +00:00

Fix: Remove thread support

Feat: cleanup api
This commit is contained in:
jcorporation 2018-08-14 16:32:52 +02:00
parent 612faa1fab
commit 7cd1ba8ab2
3 changed files with 3 additions and 15 deletions

View File

@ -659,7 +659,7 @@ function webSocketConnect() {
} }
switch (obj.type) { switch (obj.type) {
case 'state': case 'update_state':
parseState(obj); parseState(obj);
break; break;
case 'disconnected': case 'disconnected':

View File

@ -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); 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, " "state:%d, volume:%d, songPos: %d, elapsedTime: %d, "
"totalTime:%d, currentSongId: %d, kbitrate: %d, " "totalTime:%d, currentSongId: %d, kbitrate: %d, "
"audioFormat: { sampleRate: %d, bits: %d, channels: %d}, " "audioFormat: { sampleRate: %d, bits: %d, channels: %d}, "

View File

@ -28,7 +28,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <pwd.h> #include <pwd.h>
#include <pthread.h>
#include "../dist/src/mongoose/mongoose.h" #include "../dist/src/mongoose/mongoose.h"
#include "../dist/src/inih/ini.h" #include "../dist/src/inih/ini.h"
@ -38,7 +37,6 @@
static sig_atomic_t s_signal_received = 0; static sig_atomic_t s_signal_received = 0;
static struct mg_serve_http_opts s_http_server_opts; static struct mg_serve_http_opts s_http_server_opts;
char s_redirect[250]; char s_redirect[250];
struct mg_mgr mgr;
static void signal_handler(int sig_num) { static void signal_handler(int sig_num) {
signal(sig_num, signal_handler); // Reinstantiate signal handler 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; return 1;
} }
void mympd_poll_loop() {
while (s_signal_received == 0) {
mympd_poll(&mgr, 200);
}
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
struct mg_mgr mgr;
struct mg_connection *nc; struct mg_connection *nc;
struct mg_connection *nc_http; struct mg_connection *nc_http;
struct mg_bind_opts bind_opts; struct mg_bind_opts bind_opts;
@ -263,10 +255,6 @@ int main(int argc, char **argv) {
if (config.ssl == true) if (config.ssl == true)
printf("myMPD started on ssl port %s\n", config.sslport); 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 //Main loop for http handling
while (s_signal_received == 0) { while (s_signal_received == 0) {
mg_mgr_poll(&mgr, 100); mg_mgr_poll(&mgr, 100);