mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
add --max-frames-ss and --max-frames-ss-path parameters for taking a screenshot after max_frames is reached
This commit is contained in:
parent
b0146abd11
commit
b1dde87ce5
48
retroarch.c
48
retroarch.c
@ -165,7 +165,9 @@ enum
|
||||
RA_OPT_VERSION,
|
||||
RA_OPT_EOF_EXIT,
|
||||
RA_OPT_LOG_FILE,
|
||||
RA_OPT_MAX_FRAMES
|
||||
RA_OPT_MAX_FRAMES,
|
||||
RA_OPT_MAX_FRAMES_SCREENSHOT,
|
||||
RA_OPT_MAX_FRAMES_SCREENSHOT_PATH
|
||||
};
|
||||
|
||||
enum runloop_state
|
||||
@ -262,6 +264,8 @@ static msg_queue_t *runloop_msg_queue = NULL;
|
||||
|
||||
static unsigned runloop_pending_windowed_scale = 0;
|
||||
static unsigned runloop_max_frames = 0;
|
||||
static bool runloop_max_frames_screenshot = false;
|
||||
static char runloop_max_frames_screenshot_path[PATH_MAX_LENGTH] = {0};
|
||||
static unsigned fastforward_after_frames = 0;
|
||||
|
||||
static retro_usec_t runloop_frame_time_last = 0;
|
||||
@ -593,7 +597,11 @@ static void retroarch_print_help(const char *arg0)
|
||||
"Not relevant for all platforms.");
|
||||
puts(" --max-frames=NUMBER\n"
|
||||
" Runs for the specified number of frames, "
|
||||
"then exits.\n");
|
||||
"then exits.");
|
||||
puts(" --max-frames-ss\n"
|
||||
" Takes a screenshot at the end of max-frames.");
|
||||
puts(" --max-frames-ss-path=FILE\n"
|
||||
" Path to save the screenshot to at the end of max-frames.\n");
|
||||
}
|
||||
|
||||
#define FFMPEG_RECORD_ARG "r:"
|
||||
@ -667,6 +675,8 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
||||
{ "features", 0, NULL, RA_OPT_FEATURES },
|
||||
{ "subsystem", 1, NULL, RA_OPT_SUBSYSTEM },
|
||||
{ "max-frames", 1, NULL, RA_OPT_MAX_FRAMES },
|
||||
{ "max-frames-ss", 0, NULL, RA_OPT_MAX_FRAMES_SCREENSHOT },
|
||||
{ "max-frames-ss-path", 1, NULL, RA_OPT_MAX_FRAMES_SCREENSHOT_PATH },
|
||||
{ "eof-exit", 0, NULL, RA_OPT_EOF_EXIT },
|
||||
{ "version", 0, NULL, RA_OPT_VERSION },
|
||||
#ifdef HAVE_FILE_LOGGER
|
||||
@ -1088,6 +1098,14 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
||||
runloop_max_frames = (unsigned)strtoul(optarg, NULL, 10);
|
||||
break;
|
||||
|
||||
case RA_OPT_MAX_FRAMES_SCREENSHOT:
|
||||
runloop_max_frames_screenshot = true;
|
||||
break;
|
||||
|
||||
case RA_OPT_MAX_FRAMES_SCREENSHOT_PATH:
|
||||
strlcpy(runloop_max_frames_screenshot_path, optarg, sizeof(runloop_max_frames_screenshot_path));
|
||||
break;
|
||||
|
||||
case RA_OPT_SUBSYSTEM:
|
||||
path_set(RARCH_PATH_SUBSYSTEM, optarg);
|
||||
break;
|
||||
@ -2631,6 +2649,32 @@ static enum runloop_state runloop_check_state(
|
||||
|
||||
if (time_to_exit(trig_quit_key))
|
||||
{
|
||||
if ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames))
|
||||
{
|
||||
if (runloop_max_frames_screenshot)
|
||||
{
|
||||
const char *screenshot_path = NULL;
|
||||
bool fullpath = false;
|
||||
|
||||
if (string_is_empty(runloop_max_frames_screenshot_path))
|
||||
screenshot_path = path_get(RARCH_PATH_BASENAME);
|
||||
else
|
||||
{
|
||||
fullpath = true;
|
||||
screenshot_path = runloop_max_frames_screenshot_path;
|
||||
}
|
||||
|
||||
RARCH_LOG("Taking a screenshot before exiting...\n");
|
||||
|
||||
/* Take a screenshot before we exit. */
|
||||
if (!take_screenshot(screenshot_path, false,
|
||||
video_driver_cached_frame_has_valid_framebuffer(), fullpath, false))
|
||||
{
|
||||
RARCH_ERR("Could not take a screenshot before exiting.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (runloop_exec)
|
||||
runloop_exec = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user