summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2024-03-19 07:12:42 +0100
committerKacper Michajłow <kasper93@gmail.com>2024-04-07 20:23:04 +0200
commit7d2b7fa019c8c15b17dd0f48629e3ab8f00c8263 (patch)
tree6a555e1bb18876782108207a613bb7128b15e6f5 /video/out
parentc389f9e75ebbac346eb8bf7ea0f788bc86a90187 (diff)
downloadmpv-7d2b7fa019c8c15b17dd0f48629e3ab8f00c8263.tar.bz2
mpv-7d2b7fa019c8c15b17dd0f48629e3ab8f00c8263.tar.xz
vo_tct: use fwrite when appropriate
Diffstat (limited to 'video/out')
-rw-r--r--video/out/vo_tct.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/video/out/vo_tct.c b/video/out/vo_tct.c
index a1caeed8bc..1b130d0100 100644
--- a/video/out/vo_tct.c
+++ b/video/out/vo_tct.c
@@ -50,6 +50,8 @@ static const bstr TERM_ESC_COLOR24BIT_FG = bstr0_s("\033[38;2");
static const bstr UNICODE_LOWER_HALF_BLOCK = bstr0_s("\xe2\x96\x84");
+#define WRITE_STR(str) fwrite((str), strlen(str), 1, stdout)
+
enum vo_tct_buffering {
VO_TCT_BUFFER_PIXEL,
VO_TCT_BUFFER_LINE,
@@ -130,11 +132,7 @@ static void print_seq1(bstr *frame, struct lut_item *lut, bstr prefix, uint8_t c
static void print_buffer(bstr *frame)
{
-#ifdef _WIN32
- printf("%.*s", BSTR_P(*frame));
-#else
fwrite(frame->start, frame->len, 1, stdout);
-#endif
frame->len = 0;
}
@@ -249,7 +247,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
if (mp_sws_reinit(p->sws) < 0)
return -1;
- printf(TERM_ESC_CLEAR_SCREEN);
+ WRITE_STR(TERM_ESC_CLEAR_SCREEN);
vo->want_redraw = true;
return 0;
@@ -275,7 +273,7 @@ static void flip_page(struct vo *vo)
if (vo->dwidth != width || vo->dheight != height)
reconfig(vo, vo->params);
- printf(TERM_ESC_SYNC_UPDATE_BEGIN);
+ WRITE_STR(TERM_ESC_SYNC_UPDATE_BEGIN);
p->frame_buf.len = 0;
if (p->opts.algo == ALGO_PLAIN) {
@@ -294,14 +292,14 @@ static void flip_page(struct vo *vo)
if (p->opts.buffering <= VO_TCT_BUFFER_FRAME)
print_buffer(&p->frame_buf);
- printf(TERM_ESC_SYNC_UPDATE_END);
+ WRITE_STR(TERM_ESC_SYNC_UPDATE_END);
fflush(stdout);
}
static void uninit(struct vo *vo)
{
- printf(TERM_ESC_RESTORE_CURSOR);
- printf(TERM_ESC_NORMAL_SCREEN);
+ WRITE_STR(TERM_ESC_RESTORE_CURSOR);
+ WRITE_STR(TERM_ESC_NORMAL_SCREEN);
struct priv *p = vo->priv;
talloc_free(p->frame);
talloc_free(p->frame_buf.start);
@@ -324,8 +322,8 @@ static int preinit(struct vo *vo)
memcpy(p->lut[i].str, buff, 4); // some strings may not end on a null byte, but that's ok.
}
- printf(TERM_ESC_HIDE_CURSOR);
- printf(TERM_ESC_ALT_SCREEN);
+ WRITE_STR(TERM_ESC_HIDE_CURSOR);
+ WRITE_STR(TERM_ESC_ALT_SCREEN);
return 0;
}