summaryrefslogtreecommitdiff
path: root/src/fruits/cmv
diff options
context:
space:
mode:
Diffstat (limited to 'src/fruits/cmv')
-rw-r--r--src/fruits/cmv/cmv2.c13
-rw-r--r--src/fruits/cmv/tui.c14
-rw-r--r--src/fruits/cmv/tui.h5
3 files changed, 24 insertions, 8 deletions
diff --git a/src/fruits/cmv/cmv2.c b/src/fruits/cmv/cmv2.c
index d8f4fc2..3c70317 100644
--- a/src/fruits/cmv/cmv2.c
+++ b/src/fruits/cmv/cmv2.c
@@ -42,8 +42,6 @@ struct cmv {
#endif
};
-static struct cmv c;
-
static str *default_list = al_str_c("default");
static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque)
@@ -97,6 +95,10 @@ static u8 sink_callback(void *userdata, u8 op, u8 type, void *opaque)
}
}
break;
+ case CAMU_SINK_SET_BUFFERED: {
+ cap_list_pump(&c->cap, default_list, true);
+ break;
+ }
case CAMU_SINK_START:
switch (type) {
case CAMU_SINK_AUDIO: {
@@ -177,6 +179,7 @@ static bool cap_callback(void *userdata, u8 op, str *name, str *unique_id, void
return camu_sink_local_buffer(&c->sink, unique_id, (struct cch_entry *)opaque);
case CAP_SET:
camu_sink_local_set(&c->sink, unique_id);
+ al_log_info("cmv", "Now playing: %.*s.", AL_STR_PRINTF(unique_id));
break;
case CAP_SWAP:
camu_sink_local_swap(&c->sink, unique_id);
@@ -237,12 +240,14 @@ s32 main(s32 argc, char *argv[])
{
aki_common_init();
+ struct cmv c = { };
+
#if CMV_USE_TUI
if (!tui_init(&c.tui)) {
aki_common_close();
return EXIT_FAILURE;
}
- al_set_print(&c, log_callback);
+ al_set_print(log_callback, &c);
#ifdef HAVE_FFMPEG
camu_lav_set_log_callback(lav_log_callback);
#endif
@@ -297,7 +302,7 @@ s32 main(s32 argc, char *argv[])
#if CMV_USE_TUI
aki_timer_init(&c.timer, &c.loop, timer_callback, &c);
- aki_timer_set_repeat(&c.timer, 0.15);
+ aki_timer_set_repeat(&c.timer, 0.10);
aki_timer_again(&c.timer);
#endif
diff --git a/src/fruits/cmv/tui.c b/src/fruits/cmv/tui.c
index 84a1846..21aeac8 100644
--- a/src/fruits/cmv/tui.c
+++ b/src/fruits/cmv/tui.c
@@ -1,7 +1,6 @@
#include <aki/file.h>
#include <al/log.h>
#include <sys/ioctl.h>
-#include <termios.h>
#include "tui.h"
@@ -31,15 +30,22 @@ bool tui_init(struct cmv_tui *tui)
tui->height = 0;
//tui->prev_lines = 0;
- tui->fd = STDIN_FILENO;
+ tui->fd = fileno(stdin);
tui->out = fdopen(tui->fd, "w");
if (!tui->out) return false;
- setbuf(tui->out, NULL);
tui_global = tui;
aki_mutex_init(&tui->mutex);
signal(SIGWINCH, handle_winch);
+ // Disable buffer.
+ setbuf(tui->out, NULL);
+
+ // Disable echo.
+ tcgetattr(tui->fd, &tui->term);
+ tui->term.c_lflag &= ~ECHO;
+ tcsetattr(tui->fd, 0, &tui->term);
+
al_array_init(tui->log_buffer);
tui->last_pts = 0.0;
@@ -114,5 +120,7 @@ void tui_close(struct cmv_tui *tui)
aki_mutex_destroy(&tui->mutex);
fprintf(tui->out, "\n");
fflush(tui->out);
+ tui->term.c_lflag |= ECHO;
+ tcsetattr(tui->fd, 0, &tui->term);
fclose(tui->out);
}
diff --git a/src/fruits/cmv/tui.h b/src/fruits/cmv/tui.h
index 8cf58c0..fb4215e 100644
--- a/src/fruits/cmv/tui.h
+++ b/src/fruits/cmv/tui.h
@@ -1,18 +1,21 @@
#pragma once
+#include <termios.h>
+
#include "../../bimu/local.h"
#include "../../buffer/clock.h"
struct cmv_tui {
s32 fd;
FILE *out;
+ struct aki_mutex mutex;
+ struct termios term;
bool update_size;
u32 width;
u32 height;
//u32 prev_lines;
array(char *) log_buffer;
f64 last_pts;
- struct aki_mutex mutex;
};
bool tui_init(struct cmv_tui *tui);