From 987c2fb44b1113dfb6f580ebc4d7e80a61dffbfe Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Fri, 15 Jan 2021 11:09:34 +0100 Subject: [PATCH] better framing for DISPLAY MODE notif & print FPS on stdout with -fps arg --- frontend/main.c | 14 +++++++------- frontend/plugin_lib.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/frontend/main.c b/frontend/main.c index f45d89bf9..b30d3635d 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -310,13 +310,13 @@ void do_emu_action(void) case SACTION_SWITCH_DISPMODE: aspect_ratio = (aspect_ratio+1)%NB_ASPECT_RATIOS_TYPES; if(aspect_ratio == ASPECT_RATIOS_TYPE_MANUAL){ - //snprintf(hud_msg, sizeof(hud_msg), "DISPLAY MODE: MANUAL ZOOM %d%%", aspect_ratio_factor_percent); - sprintf(shell_cmd, "%s %d \"DISPLAY MODE: MANUAL ZOOM %d%%%%\"", + //snprintf(hud_msg, sizeof(hud_msg), " DISPLAY MODE: ZOOMED %d%%", aspect_ratio_factor_percent); + sprintf(shell_cmd, "%s %d \" DISPLAY MODE: ZOOMED %d%%%%\"", SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent); } else{ //snprintf(hud_msg, sizeof(hud_msg), "DISPLAY MODE: %s", aspect_ratio_name[aspect_ratio]); - sprintf(shell_cmd, "%s %d \" DISPLAY MODE: %s\"", + sprintf(shell_cmd, "%s %d \" DISPLAY MODE: %s\"", SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_name[aspect_ratio]); } //hud_new_msg = 4; @@ -334,9 +334,9 @@ void do_emu_action(void) else{ aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL; } - /*snprintf(hud_msg, sizeof(hud_msg), "DISPLAY MODE: MANUAL ZOOM %d%%", aspect_ratio_factor_percent); + /*snprintf(hud_msg, sizeof(hud_msg), " DISPLAY MODE: ZOOMED %d%%", aspect_ratio_factor_percent); hud_new_msg = 4;*/ - sprintf(shell_cmd, "%s %d \"DISPLAY MODE: MANUAL ZOOM %d%%%%\"", + sprintf(shell_cmd, "%s %d \" DISPLAY MODE: ZOOMED %d%%%%\"", SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent); fp = popen(shell_cmd, "r"); if (fp == NULL) { @@ -353,9 +353,9 @@ void do_emu_action(void) aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL; } aspect_ratio = ASPECT_RATIOS_TYPE_MANUAL; - /*snprintf(hud_msg, sizeof(hud_msg), "DISPLAY MODE: MANUAL ZOOM %d%%", aspect_ratio_factor_percent); + /*snprintf(hud_msg, sizeof(hud_msg), " DISPLAY MODE: ZOOMED %d%%", aspect_ratio_factor_percent); hud_new_msg = 4;*/ - sprintf(shell_cmd, "%s %d \"DISPLAY MODE: MANUAL ZOOM %d%%%%\"", + sprintf(shell_cmd, "%s %d \" DISPLAY MODE: ZOOMED %d%%%%\"", SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent); fp = popen(shell_cmd, "r"); if (fp == NULL) { diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 5ba707ae0..c290996cb 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -111,6 +111,26 @@ static void print_fps(int h, int border) hud_printf(pl_vout_buf, pl_vout_w, border + 2, h - HUD_HEIGHT, "%2d %4.1f", pl_rearmed_cbs.flips_per_sec, pl_rearmed_cbs.vsps_cur); + +#define PRINT_FPS_AVG 200 +#ifdef PRINT_FPS_AVG + static int flip_per_sec_avg = 0; + static float vsps_cur_avg = 0; + static int fps_measurements = 0; + + flip_per_sec_avg += pl_rearmed_cbs.flips_per_sec; + vsps_cur_avg += pl_rearmed_cbs.vsps_cur; + fps_measurements++; + + if(fps_measurements >= PRINT_FPS_AVG){ + printf("FPS=%2d %4.1f\n", flip_per_sec_avg/fps_measurements, vsps_cur_avg/fps_measurements); + + flip_per_sec_avg = 0; + vsps_cur_avg = 0; + fps_measurements = 0; + } + +#endif //PRINT_FPS_AVG } static void print_cpu_usage(int w, int h, int border)