diff options
Diffstat (limited to 'src/fruits')
| -rw-r--r-- | src/fruits/cmv/cmv2.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/fruits/cmv/cmv2.c b/src/fruits/cmv/cmv2.c index a7b688c..963cf7a 100644 --- a/src/fruits/cmv/cmv2.c +++ b/src/fruits/cmv/cmv2.c @@ -1,4 +1,5 @@ #define CMV_USE_TUI 1 +#define CMV_USE_SOCKET 1 #include <al/log.h> #include <aki/line_processor.h> @@ -28,9 +29,11 @@ struct cmv { struct camu_mixer mixer; struct aki_event_loop loop; struct camu_sink sink; + struct cap_runner cap; +#if CMV_USE_SOCKET struct aki_socket socket; struct aki_line_processor pro; - struct cap_runner cap; +#endif #if CMV_USE_TUI struct cmv_tui tui; struct aki_timer timer; @@ -38,6 +41,7 @@ struct cmv { }; static struct cmv c; + static str *default_list = al_str_c("default"); static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque) @@ -121,8 +125,11 @@ static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque) } break; case CAMU_SINK_EXIT: - aki_event_loop_break(&c->loop); +#if CMV_USE_SOCKET + aki_line_processor_stop(&c->pro); +#endif camu_sink_close(&c->sink); + aki_event_loop_break(&c->loop); break; } return CAMU_SINK_OK; @@ -132,9 +139,6 @@ static void screen_callback(void *userdata, u8 op, f64 float0) { struct cmv *c = (struct cmv *)userdata; switch (op) { - case CAMU_SCREEN_CLOSE: - c->quit = 1; - break; case CAMU_SCREEN_NEXT: cap_list_skip(&c->cap, default_list, 1); break; @@ -147,7 +151,8 @@ static void screen_callback(void *userdata, u8 op, f64 float0) case CAMU_SCREEN_SEEK: camu_sink_seek(&c->sink, float0); break; - default: + case CAMU_SCREEN_CLOSE: + c->quit = 1; break; } } @@ -180,7 +185,7 @@ static bool cap_callback(void *userdata, u8 op, str *name, str *unique_id, void return true; } -#ifndef _WIN32 +#if CMV_USE_SOCKET static u8 line_callback(void *userdata, str *line) { struct cmv *c = (struct cmv *)userdata; @@ -274,11 +279,10 @@ s32 main(s32 argc, char *argv[]) cap_list_add(&c.cap, default_list, al_str_c(argv[i])); } -#ifndef _WIN32 +#if CMV_USE_SOCKET c.socket.type = AKI_SOCKET_UNIX; aki_socket_init(&c.socket); aki_socket_set_blocking(&c.socket, false); - aki_socket_set_no_delay(&c.socket, 1); c.pro.callback = line_callback; c.pro.userdata = &c; aki_line_processor_init(&c.pro, al_str_c("\n")); |