From 7852aff0c4b29e0de9a16b74e0d9d1d4cd6586ec Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 5 Mar 2010 20:15:16 +0000 Subject: Reuse fb_tty_fd for setting up the text area. This avoids the fopen call which could end up creating a /dev/tty file if it did not exist. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30846 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_fbdev.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_fbdev.c b/libvo/vo_fbdev.c index c3341858c2..075b6486ed 100644 --- a/libvo/vo_fbdev.c +++ b/libvo/vo_fbdev.c @@ -554,9 +554,6 @@ char *fb_mode_name = NULL; static fb_mode_t *fb_mode = NULL; -/* vt related variables */ -static FILE *vt_fp = NULL; - /* vo_fbdev related variables */ static int fb_dev_fd; static int fb_tty_fd = -1; @@ -736,9 +733,11 @@ static void vt_set_textarea(int u, int l) int lrow = l / 16; mp_msg(MSGT_VO, MSGL_DBG2, "vt_set_textarea(%d,%d): %d,%d\n", u, l, urow, lrow); - if (vt_fp) { - fprintf(vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0); - fflush(vt_fp); + if (fb_tty_fd >= 0) { + char modestring[100]; + snprintf(modestring, sizeof(modestring), "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0); + write(fb_tty_fd, modestring, strlen(modestring)); + fsync(fb_tty_fd); } } @@ -973,9 +972,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, if (fs || vm) memset(frame_buffer, '\0', fb_line_len * fb_yres); } - if (!(vt_fp = fopen("/dev/tty", "w"))) { - mp_msg(MSGT_VO, MSGL_ERR, "can't fopen /dev/tty: %s\n", strerror(errno)); - } vt_set_textarea(last_row, fb_yres); @@ -1056,8 +1052,6 @@ static void uninit(void) mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno)); } vt_set_textarea(0, fb_orig_vinfo.yres); - if (vt_fp) - fclose(vt_fp); close(fb_tty_fd); close(fb_dev_fd); if (frame_buffer) -- cgit v1.2.3