Skip to content

Commit ef2f001

Browse files
committed
video_display: Report frames dropped by display
1 parent de37b4d commit ef2f001

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/video_display.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct display {
106106

107107
time_ns_t t0;
108108
int frames;
109+
int dropped;
109110
};
110111

111112
void list_video_display_devices(bool full)
@@ -352,17 +353,22 @@ struct video_frame *display_get_frame(struct display *d)
352353
* indicator but externally linked for those that do not, like vulkan_sdl3.
353354
*/
354355
void
355-
display_print_fps(const char *prefix, double seconds, int frames,
356+
display_print_fps(const char *prefix, double seconds, int frames, int dropped,
356357
double nominal_fps)
357358
{
358359
const double fps = frames / seconds;
359360
const char *const fps_col = get_stat_color(fps / nominal_fps);
360361

362+
char drop_str[32] = "";
363+
if(dropped > 0){
364+
snprintf(drop_str, sizeof(drop_str), " (%d frames dropped)", dropped);
365+
}
366+
361367
log_msg(LOG_LEVEL_INFO,
362368
TERM_BOLD TERM_FG_MAGENTA "%s" TERM_RESET
363369
"%d frames in %g seconds = " TERM_BOLD
364-
"%s%g FPS" TERM_RESET "\n",
365-
prefix, frames, seconds, fps_col, fps);
370+
"%s%g FPS%s" TERM_RESET "\n",
371+
prefix, frames, seconds, fps_col, fps, drop_str);
366372
}
367373

368374
static bool display_frame_helper(struct display *d, struct video_frame *frame, long long timeout_ns)
@@ -378,16 +384,19 @@ static bool display_frame_helper(struct display *d, struct video_frame *frame, l
378384
}
379385
if (ret) {
380386
d->frames++;
387+
} else{
388+
d->dropped++;
381389
}
382390
// display FPS
383391
time_ns_t t = get_time_in_ns();
384392
long long seconds_ns = t - d->t0;
385393
if (seconds_ns > 5 * NS_IN_SEC) {
386394
const double seconds = (double) seconds_ns / NS_IN_SEC;
387395
display_print_fps(d->funcs->generic_fps_indicator_prefix,
388-
seconds, d->frames, frame_fps);
396+
seconds, d->frames, d->dropped, frame_fps);
389397

390398
d->frames = 0;
399+
d->dropped = 0;
391400
d->t0 = t;
392401
}
393402
return ret;

src/video_display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ bool display_reconfigure_audio(struct display *d, int quant_
211211
struct video_frame *get_splashscreen(void);
212212
const char *get_audio_conn_flag_name(int audio_init_flag);
213213

214-
void display_print_fps(const char *prefix, double seconds, int frames,
214+
void display_print_fps(const char *prefix, double seconds, int frames, int dropped,
215215
double nominal_fps);
216216

217217
#ifdef __cplusplus

0 commit comments

Comments
 (0)