mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 15:40:21 +00:00
moved FPS indicator prefix trailing ' ' trim
moved to video_capture.cpp - it is a bit technical and it is nicer to have it there than in the huge main.cpp
This commit is contained in:
@@ -318,10 +318,8 @@ static void *capture_thread(void *arg)
|
||||
struct wait_obj *wait_obj = wait_obj_init();
|
||||
steady_clock::time_point t0 = steady_clock::now();
|
||||
int frames = 0;
|
||||
char *print_fps_prefix = vidcap_get_fps_print_prefix(uv->capture_device) ? strdupa(vidcap_get_fps_print_prefix(uv->capture_device)) : NULL;
|
||||
if (print_fps_prefix && print_fps_prefix[strlen(print_fps_prefix) - 1] == ' ') { // trim trailing ' '
|
||||
print_fps_prefix[strlen(print_fps_prefix) - 1] = '\0';
|
||||
}
|
||||
const char *print_fps_prefix =
|
||||
vidcap_get_fps_print_prefix(uv->capture_device);
|
||||
|
||||
while (!uv->should_exit_capture) {
|
||||
/* Capture and transmit video... */
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
/// the following limits are used mostly for static array allocations
|
||||
enum {
|
||||
MAX_CPU_CORES = 256, ///< maximal expected CPU core count
|
||||
SHORT_STR = 128,
|
||||
STR_LEN = 2048, ///< "standard" string length placeholder
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* @ingroup vidcap
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2005-2023 CESNET, z. s. p. o.
|
||||
* Copyright (c) 2005-2024 CESNET
|
||||
* Copyright (c) 2001-2004 University of Southern California
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "debug.h"
|
||||
#include "lib_common.h"
|
||||
#include "module.h"
|
||||
#include "utils/macros.h"
|
||||
#include "video_capture.h"
|
||||
#include "video_capture_params.h"
|
||||
|
||||
@@ -229,12 +230,26 @@ struct video_frame *vidcap_grab(struct vidcap *state, struct audio_frame **audio
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief If not-NULL returned, display doesn't hae own FPS indicator and wants
|
||||
* to use a generic one (prefixed with returned module name)
|
||||
* @returns nullptr if display has own FPS indicator
|
||||
* @returns otherwise the prefix (without trailing space, eg. "[GL]") to be used
|
||||
* in a generic fps indicator
|
||||
*/
|
||||
const char *vidcap_get_fps_print_prefix(struct vidcap *state)
|
||||
{
|
||||
assert(state->magic == VIDCAP_MAGIC);
|
||||
return state->funcs->generic_fps_indicator_prefix;
|
||||
if (state->funcs->generic_fps_indicator_prefix == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
thread_local char buf[SHORT_STR];
|
||||
|
||||
unsigned len = snprintf(buf, sizeof buf, "%s",
|
||||
state->funcs->generic_fps_indicator_prefix);
|
||||
if (len > sizeof buf - 1) { // truncated
|
||||
len = sizeof buf - 1;
|
||||
}
|
||||
if (len > 0 && buf[len - 1] == ' ') { // trim trailing ' '
|
||||
buf[len - 1] = '\0';
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user