2023-01-25 06:15:32 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2016-2019 - Brad Parker
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_BSV_MOVIE
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2023-03-07 23:10:59 +00:00
|
|
|
#include <time/rtime.h>
|
2023-01-25 06:15:32 +00:00
|
|
|
#include <compat/strl.h>
|
2023-01-31 04:34:26 +00:00
|
|
|
#include <file/file_path.h>
|
Replay UI support (#15048)
* Add bsv replay controls (not yet fully implemented), remove toggle
see notes in task_movie.c, make sure command.c calls the right
functions, check retroarch.c and other todos.
bsv files are also now stored with states, not saves.
* Compilation fixes
* Added command impls for play and record replay, and some code in load state to do the right thing there
* Guard some parts of the new code with HAVE_BSV_MOVIE
* wip, menu fixes
* more menu fixes, osd for movie errors, halt recording properly
* Menu and label fixes
* move bsvs to own file suffix series under savestates, fix recording and playback command validity checks
* Fix replay autoincrement
* fix endif placement, whoops
---------
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-03-02 23:52:22 +00:00
|
|
|
#include <streams/file_stream.h>
|
2023-05-30 19:03:36 +00:00
|
|
|
#include <retro_endianness.h>
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <direct.h>
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "../msg_hash.h"
|
|
|
|
#include "../verbosity.h"
|
|
|
|
#include "../core.h"
|
|
|
|
#include "../content.h"
|
|
|
|
#include "../runloop.h"
|
|
|
|
#include "tasks_internal.h"
|
|
|
|
#include "../input/input_driver.h"
|
|
|
|
|
|
|
|
#define MAGIC_INDEX 0
|
2023-03-07 23:10:59 +00:00
|
|
|
#define VERSION_INDEX 1
|
2023-01-25 06:15:32 +00:00
|
|
|
#define CRC_INDEX 2
|
|
|
|
#define STATE_SIZE_INDEX 3
|
2023-03-07 23:10:59 +00:00
|
|
|
/* Identifier is int64_t, so takes up two slots */
|
|
|
|
#define IDENTIFIER_INDEX 4
|
|
|
|
#define HEADER_LEN 6
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-03-07 23:10:59 +00:00
|
|
|
#define REPLAY_FORMAT_VERSION 0
|
|
|
|
#define REPLAY_MAGIC 0x42535632
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
/* Forward declaration */
|
|
|
|
bool content_load_state_in_progress(void* data);
|
|
|
|
|
2023-01-25 06:15:32 +00:00
|
|
|
/* Private functions */
|
|
|
|
|
|
|
|
static bool bsv_movie_init_playback(
|
|
|
|
bsv_movie_t *handle, const char *path)
|
|
|
|
{
|
2023-03-07 23:10:59 +00:00
|
|
|
int64_t *identifier_loc;
|
|
|
|
uint32_t state_size = 0;
|
|
|
|
uint32_t header[HEADER_LEN] = {0};
|
|
|
|
intfstream_t *file = intfstream_open_file(path,
|
2023-01-25 06:15:32 +00:00
|
|
|
RETRO_VFS_FILE_ACCESS_READ,
|
|
|
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
|
|
|
|
|
|
|
if (!file)
|
|
|
|
{
|
2023-03-03 22:16:48 +00:00
|
|
|
RARCH_ERR("Could not open replay file for playback, path : \"%s\".\n", path);
|
2023-01-25 06:15:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
handle->file = file;
|
|
|
|
handle->playback = true;
|
|
|
|
|
2023-03-07 23:10:59 +00:00
|
|
|
intfstream_read(handle->file, header, sizeof(uint32_t) * HEADER_LEN);
|
|
|
|
if (swap_if_big32(header[MAGIC_INDEX]) != REPLAY_MAGIC)
|
2023-01-25 06:15:32 +00:00
|
|
|
{
|
2023-03-07 23:10:59 +00:00
|
|
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_MOVIE_FILE_IS_NOT_A_VALID_REPLAY_FILE));
|
2023-01-25 06:15:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-04-23 14:09:24 +00:00
|
|
|
#if 0
|
2023-03-07 23:10:59 +00:00
|
|
|
if (swap_if_big32(header[VERSION_INDEX]) > REPLAY_FORMAT_VERSION)
|
|
|
|
{
|
|
|
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_MOVIE_FILE_IS_NOT_A_VALID_REPLAY_FILE));
|
|
|
|
return false;
|
|
|
|
}
|
2023-04-23 14:09:24 +00:00
|
|
|
#endif
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-04-23 14:09:24 +00:00
|
|
|
state_size = swap_if_big32(header[STATE_SIZE_INDEX]);
|
|
|
|
identifier_loc = (int64_t *)(header+IDENTIFIER_INDEX);
|
2023-03-07 23:10:59 +00:00
|
|
|
handle->identifier = swap_if_big64(*identifier_loc);
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
RARCH_ERR("----- debug %u -----\n", header[0]);
|
|
|
|
RARCH_ERR("----- debug %u -----\n", header[1]);
|
|
|
|
RARCH_ERR("----- debug %u -----\n", header[2]);
|
|
|
|
RARCH_ERR("----- debug %u -----\n", header[3]);
|
2023-03-07 23:10:59 +00:00
|
|
|
RARCH_ERR("----- debug %u -----\n", header[4]);
|
|
|
|
RARCH_ERR("----- debug %u -----\n", header[5]);
|
2023-01-25 06:15:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (state_size)
|
|
|
|
{
|
2023-06-16 15:20:27 +00:00
|
|
|
size_t info_size;
|
2023-01-25 06:15:32 +00:00
|
|
|
retro_ctx_serialize_info_t serial_info;
|
|
|
|
uint8_t *buf = (uint8_t*)malloc(state_size);
|
|
|
|
|
|
|
|
if (!buf)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
handle->state = buf;
|
|
|
|
handle->state_size = state_size;
|
|
|
|
if (intfstream_read(handle->file,
|
|
|
|
handle->state, state_size) != state_size)
|
|
|
|
{
|
|
|
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_COULD_NOT_READ_STATE_FROM_MOVIE));
|
|
|
|
return false;
|
|
|
|
}
|
2023-06-16 15:20:27 +00:00
|
|
|
info_size = core_serialize_size();
|
2023-02-02 19:44:30 +00:00
|
|
|
/* For cores like dosbox, the reported size is not always
|
|
|
|
correct. So we just give a warning if they don't match up. */
|
|
|
|
serial_info.data_const = handle->state;
|
|
|
|
serial_info.size = state_size;
|
|
|
|
core_unserialize(&serial_info);
|
2023-06-16 15:20:27 +00:00
|
|
|
if (info_size != state_size)
|
2023-01-25 06:15:32 +00:00
|
|
|
{
|
|
|
|
RARCH_WARN("%s\n",
|
|
|
|
msg_hash_to_str(MSG_MOVIE_FORMAT_DIFFERENT_SERIALIZER_VERSION));
|
2023-02-02 19:44:30 +00:00
|
|
|
}
|
2023-01-25 06:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handle->min_file_pos = sizeof(header) + state_size;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool bsv_movie_init_record(
|
|
|
|
bsv_movie_t *handle, const char *path)
|
|
|
|
{
|
2023-06-16 15:20:27 +00:00
|
|
|
size_t info_size;
|
2023-03-07 23:10:59 +00:00
|
|
|
time_t t = time(NULL);
|
|
|
|
time_t time_lil = swap_if_big64(t);
|
|
|
|
uint32_t state_size = 0;
|
|
|
|
uint32_t content_crc = 0;
|
|
|
|
uint32_t header[HEADER_LEN] = {0};
|
|
|
|
intfstream_t *file = intfstream_open_file(path,
|
|
|
|
RETRO_VFS_FILE_ACCESS_WRITE | RETRO_VFS_FILE_ACCESS_READ,
|
2023-01-25 06:15:32 +00:00
|
|
|
RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
|
|
|
|
|
|
|
if (!file)
|
|
|
|
{
|
2023-03-03 22:16:48 +00:00
|
|
|
RARCH_ERR("Could not open replay file for recording, path : \"%s\".\n", path);
|
2023-01-25 06:15:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
handle->file = file;
|
|
|
|
|
|
|
|
content_crc = content_get_crc();
|
|
|
|
|
2023-03-07 23:10:59 +00:00
|
|
|
header[MAGIC_INDEX] = swap_if_big32(REPLAY_MAGIC);
|
|
|
|
header[VERSION_INDEX] = REPLAY_FORMAT_VERSION;
|
2023-01-25 06:15:32 +00:00
|
|
|
header[CRC_INDEX] = swap_if_big32(content_crc);
|
2023-03-07 23:10:59 +00:00
|
|
|
|
2023-06-16 15:20:27 +00:00
|
|
|
info_size = core_serialize_size();
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-06-16 15:20:27 +00:00
|
|
|
state_size = (unsigned)info_size;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
header[STATE_SIZE_INDEX] = swap_if_big32(state_size);
|
2023-03-07 23:10:59 +00:00
|
|
|
handle->identifier = (int64_t)t;
|
|
|
|
*((int64_t *)(header+IDENTIFIER_INDEX)) = time_lil;
|
|
|
|
intfstream_write(handle->file, header, HEADER_LEN * sizeof(uint32_t));
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
handle->min_file_pos = sizeof(header) + state_size;
|
|
|
|
handle->state_size = state_size;
|
|
|
|
|
|
|
|
if (state_size)
|
|
|
|
{
|
|
|
|
retro_ctx_serialize_info_t serial_info;
|
|
|
|
uint8_t *st = (uint8_t*)malloc(state_size);
|
|
|
|
|
|
|
|
if (!st)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
handle->state = st;
|
|
|
|
|
|
|
|
serial_info.data = handle->state;
|
|
|
|
serial_info.size = state_size;
|
|
|
|
|
|
|
|
core_serialize(&serial_info);
|
|
|
|
|
|
|
|
intfstream_write(handle->file,
|
|
|
|
handle->state, state_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void bsv_movie_free(bsv_movie_t *handle)
|
|
|
|
{
|
|
|
|
intfstream_close(handle->file);
|
|
|
|
free(handle->file);
|
|
|
|
|
|
|
|
free(handle->state);
|
|
|
|
free(handle->frame_pos);
|
|
|
|
free(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bsv_movie_t *bsv_movie_init_internal(const char *path, enum rarch_movie_type type)
|
|
|
|
{
|
|
|
|
size_t *frame_pos = NULL;
|
|
|
|
bsv_movie_t *handle = (bsv_movie_t*)calloc(1, sizeof(*handle));
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (type == RARCH_MOVIE_PLAYBACK)
|
|
|
|
{
|
|
|
|
if (!bsv_movie_init_playback(handle, path))
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
else if (!bsv_movie_init_record(handle, path))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Just pick something really large
|
|
|
|
* ~1 million frames rewind should do the trick. */
|
|
|
|
if (!(frame_pos = (size_t*)calloc((1 << 20), sizeof(size_t))))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
handle->frame_pos = frame_pos;
|
|
|
|
|
|
|
|
handle->frame_pos[0] = handle->min_file_pos;
|
|
|
|
handle->frame_mask = (1 << 20) - 1;
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (handle)
|
|
|
|
bsv_movie_free(handle);
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-02-21 10:10:25 +00:00
|
|
|
|
|
|
|
static bool bsv_movie_start_record(input_driver_state_t * input_st, char *path)
|
2023-01-25 06:15:32 +00:00
|
|
|
{
|
2023-04-30 17:30:07 +00:00
|
|
|
size_t _len;
|
2023-01-25 06:15:32 +00:00
|
|
|
char msg[8192];
|
2023-02-21 10:10:25 +00:00
|
|
|
bsv_movie_t *state = NULL;
|
2023-04-30 17:30:07 +00:00
|
|
|
const char *movie_rec_str = NULL;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
/* this should trigger a start recording task which on failure or
|
|
|
|
success prints a message and on success sets the
|
|
|
|
input_st->bsv_movie_state_handle. */
|
|
|
|
if (!(state = bsv_movie_init_internal(path, RARCH_MOVIE_RECORD)))
|
2023-02-21 10:10:25 +00:00
|
|
|
{
|
|
|
|
const char *movie_rec_fail_str =
|
2023-01-25 06:15:32 +00:00
|
|
|
msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD);
|
2023-02-21 10:10:25 +00:00
|
|
|
runloop_msg_queue_push(movie_rec_fail_str,
|
|
|
|
1, 180, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
RARCH_ERR("%s.\n", movie_rec_fail_str);
|
|
|
|
return false;
|
|
|
|
}
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-10-04 07:53:51 +00:00
|
|
|
bsv_movie_enqueue(input_st, state, BSV_FLAG_MOVIE_RECORDING);
|
2023-04-30 17:30:07 +00:00
|
|
|
movie_rec_str = msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO);
|
|
|
|
_len = strlcpy(msg, movie_rec_str, sizeof(msg));
|
|
|
|
snprintf(msg + _len, sizeof(msg) - _len, " \"%s\".", path);
|
2023-01-25 06:15:32 +00:00
|
|
|
runloop_msg_queue_push(msg, 2, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
RARCH_LOG("%s \"%s\".\n", movie_rec_str, path);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
static bool bsv_movie_start_playback(input_driver_state_t *input_st, char *path)
|
|
|
|
{
|
|
|
|
bsv_movie_t *state = NULL;
|
|
|
|
const char *starting_movie_str = NULL;
|
|
|
|
/* This should trigger a start playback task which on failure or
|
|
|
|
success prints a message and on success sets the
|
|
|
|
input_st->bsv_movie_state_handle. */
|
|
|
|
if (!(state = bsv_movie_init_internal(path, RARCH_MOVIE_PLAYBACK)))
|
|
|
|
{
|
2023-01-25 06:15:32 +00:00
|
|
|
RARCH_ERR("%s: \"%s\".\n",
|
2023-02-21 10:10:25 +00:00
|
|
|
msg_hash_to_str(MSG_FAILED_TO_LOAD_MOVIE_FILE),
|
|
|
|
path);
|
2023-01-25 06:15:32 +00:00
|
|
|
return false;
|
2023-02-21 10:10:25 +00:00
|
|
|
}
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-10-04 07:53:51 +00:00
|
|
|
bsv_movie_enqueue(input_st, state, BSV_FLAG_MOVIE_PLAYBACK);
|
2023-02-21 10:10:25 +00:00
|
|
|
starting_movie_str =
|
|
|
|
msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK);
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
runloop_msg_queue_push(starting_movie_str,
|
|
|
|
2, 180, false,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
RARCH_LOG("%s.\n", starting_movie_str);
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
return true;
|
2023-01-25 06:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Task infrastructure (also private) */
|
|
|
|
|
|
|
|
/* Future: replace stop functions with tasks that do the same. then
|
|
|
|
later we can replace the start_record/start_playback flags and
|
|
|
|
remove the entirety of input_driver_st bsv_state, which is only
|
|
|
|
needed due to mixing sync and async during initialization. */
|
|
|
|
typedef struct bsv_state moviectl_task_state_t;
|
|
|
|
|
|
|
|
static void task_moviectl_playback_handler(retro_task_t *task)
|
|
|
|
{
|
|
|
|
/* trivial handler */
|
|
|
|
task_set_finished(task, true);
|
|
|
|
if (!task_get_error(task) && task_get_cancelled(task))
|
|
|
|
task_set_error(task, strdup("Task canceled"));
|
|
|
|
|
|
|
|
task_set_data(task, task->state);
|
|
|
|
task->state = NULL;
|
|
|
|
/* no need to free state here since I'm recycling it as data */
|
|
|
|
}
|
2023-02-21 10:10:25 +00:00
|
|
|
|
2023-01-25 06:15:32 +00:00
|
|
|
static void moviectl_start_playback_cb(retro_task_t *task,
|
2023-02-21 10:10:25 +00:00
|
|
|
void *task_data,
|
|
|
|
void *user_data, const char *error)
|
2023-01-25 06:15:32 +00:00
|
|
|
{
|
2023-02-21 10:10:25 +00:00
|
|
|
struct bsv_state *state = (struct bsv_state *)task_data;
|
2023-01-25 06:15:32 +00:00
|
|
|
input_driver_state_t *input_st = input_state_get_ptr();
|
2023-02-21 10:10:25 +00:00
|
|
|
input_st->bsv_movie_state = *state;
|
2023-01-31 04:34:26 +00:00
|
|
|
bsv_movie_start_playback(input_st, state->movie_start_path);
|
2023-01-25 06:15:32 +00:00
|
|
|
free(state);
|
|
|
|
}
|
2023-02-21 10:10:25 +00:00
|
|
|
|
2023-01-25 06:15:32 +00:00
|
|
|
static void task_moviectl_record_handler(retro_task_t *task)
|
|
|
|
{
|
2023-02-21 10:10:25 +00:00
|
|
|
/* Hang on until the state is loaded */
|
2023-02-23 12:15:14 +00:00
|
|
|
if (content_load_state_in_progress(NULL))
|
2023-02-21 10:10:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* trivial handler */
|
|
|
|
task_set_finished(task, true);
|
|
|
|
if (!task_get_error(task) && task_get_cancelled(task))
|
|
|
|
task_set_error(task, strdup("Task canceled"));
|
|
|
|
|
|
|
|
task_set_data(task, task->state);
|
|
|
|
task->state = NULL;
|
|
|
|
/* no need to free state here since I'm recycling it as data */
|
2023-01-25 06:15:32 +00:00
|
|
|
}
|
2023-02-21 10:10:25 +00:00
|
|
|
|
2023-01-25 06:15:32 +00:00
|
|
|
static void moviectl_start_record_cb(retro_task_t *task,
|
2023-02-21 10:10:25 +00:00
|
|
|
void *task_data,
|
|
|
|
void *user_data, const char *error)
|
2023-01-25 06:15:32 +00:00
|
|
|
{
|
2023-02-21 10:10:25 +00:00
|
|
|
struct bsv_state *state = (struct bsv_state *)task_data;
|
2023-01-25 06:15:32 +00:00
|
|
|
input_driver_state_t *input_st = input_state_get_ptr();
|
2023-02-21 10:10:25 +00:00
|
|
|
input_st->bsv_movie_state = *state;
|
2023-01-31 04:34:26 +00:00
|
|
|
bsv_movie_start_record(input_st, state->movie_start_path);
|
2023-01-25 06:15:32 +00:00
|
|
|
free(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Public functions */
|
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
/* In the future this should probably be a deferred task as well */
|
|
|
|
bool movie_stop_playback(input_driver_state_t *input_st)
|
|
|
|
{
|
|
|
|
const char *movie_playback_end_str = NULL;
|
|
|
|
/* Checks if movie is being played back. */
|
|
|
|
if (!(input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_PLAYBACK))
|
2023-01-25 06:15:32 +00:00
|
|
|
return false;
|
2023-02-21 10:10:25 +00:00
|
|
|
movie_playback_end_str = msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED);
|
|
|
|
runloop_msg_queue_push(
|
|
|
|
movie_playback_end_str, 2, 180, false,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
RARCH_LOG("%s\n", movie_playback_end_str);
|
|
|
|
|
2023-10-04 07:53:51 +00:00
|
|
|
bsv_movie_deinit_full(input_st);
|
2023-02-21 10:10:25 +00:00
|
|
|
|
|
|
|
input_st->bsv_movie_state.flags &= ~(
|
|
|
|
BSV_FLAG_MOVIE_END
|
|
|
|
| BSV_FLAG_MOVIE_PLAYBACK);
|
|
|
|
return true;
|
2023-01-25 06:15:32 +00:00
|
|
|
}
|
|
|
|
/* in the future this should probably be a deferred task as well */
|
2023-02-21 10:10:25 +00:00
|
|
|
bool movie_stop_record(input_driver_state_t *input_st)
|
|
|
|
{
|
|
|
|
const char *movie_rec_stopped_str = msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED);
|
2023-02-23 12:15:14 +00:00
|
|
|
if (!(input_st->bsv_movie_state_handle))
|
2023-01-25 06:15:32 +00:00
|
|
|
return false;
|
2023-02-21 10:10:25 +00:00
|
|
|
runloop_msg_queue_push(movie_rec_stopped_str,
|
|
|
|
2, 180, true,
|
|
|
|
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
|
|
|
RARCH_LOG("%s\n", movie_rec_stopped_str);
|
2023-10-04 07:53:51 +00:00
|
|
|
bsv_movie_deinit_full(input_st);
|
Replay UI support (#15048)
* Add bsv replay controls (not yet fully implemented), remove toggle
see notes in task_movie.c, make sure command.c calls the right
functions, check retroarch.c and other todos.
bsv files are also now stored with states, not saves.
* Compilation fixes
* Added command impls for play and record replay, and some code in load state to do the right thing there
* Guard some parts of the new code with HAVE_BSV_MOVIE
* wip, menu fixes
* more menu fixes, osd for movie errors, halt recording properly
* Menu and label fixes
* move bsvs to own file suffix series under savestates, fix recording and playback command validity checks
* Fix replay autoincrement
* fix endif placement, whoops
---------
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-03-02 23:52:22 +00:00
|
|
|
input_st->bsv_movie_state.flags &= ~(
|
|
|
|
BSV_FLAG_MOVIE_END
|
|
|
|
| BSV_FLAG_MOVIE_RECORDING);
|
2023-02-21 10:10:25 +00:00
|
|
|
return true;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
}
|
2023-02-21 10:10:25 +00:00
|
|
|
|
|
|
|
bool movie_stop(input_driver_state_t *input_st)
|
|
|
|
{
|
|
|
|
if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_PLAYBACK)
|
2023-01-25 06:15:32 +00:00
|
|
|
return movie_stop_playback(input_st);
|
Replay UI support (#15048)
* Add bsv replay controls (not yet fully implemented), remove toggle
see notes in task_movie.c, make sure command.c calls the right
functions, check retroarch.c and other todos.
bsv files are also now stored with states, not saves.
* Compilation fixes
* Added command impls for play and record replay, and some code in load state to do the right thing there
* Guard some parts of the new code with HAVE_BSV_MOVIE
* wip, menu fixes
* more menu fixes, osd for movie errors, halt recording properly
* Menu and label fixes
* move bsvs to own file suffix series under savestates, fix recording and playback command validity checks
* Fix replay autoincrement
* fix endif placement, whoops
---------
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-03-02 23:52:22 +00:00
|
|
|
else if (input_st->bsv_movie_state.flags & BSV_FLAG_MOVIE_RECORDING)
|
2023-01-25 06:15:32 +00:00
|
|
|
return movie_stop_record(input_st);
|
Replay UI support (#15048)
* Add bsv replay controls (not yet fully implemented), remove toggle
see notes in task_movie.c, make sure command.c calls the right
functions, check retroarch.c and other todos.
bsv files are also now stored with states, not saves.
* Compilation fixes
* Added command impls for play and record replay, and some code in load state to do the right thing there
* Guard some parts of the new code with HAVE_BSV_MOVIE
* wip, menu fixes
* more menu fixes, osd for movie errors, halt recording properly
* Menu and label fixes
* move bsvs to own file suffix series under savestates, fix recording and playback command validity checks
* Fix replay autoincrement
* fix endif placement, whoops
---------
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-03-02 23:52:22 +00:00
|
|
|
if(input_st->bsv_movie_state_handle)
|
|
|
|
RARCH_ERR("Didn't really stop movie!\n");
|
2023-02-21 10:10:25 +00:00
|
|
|
return true;
|
2023-01-25 06:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool movie_start_playback(input_driver_state_t *input_st, char *path)
|
|
|
|
{
|
|
|
|
retro_task_t *task = task_init();
|
2023-04-30 17:30:07 +00:00
|
|
|
moviectl_task_state_t *state = (moviectl_task_state_t *)calloc(1, sizeof(*state));
|
|
|
|
bool file_exists = filestream_exists(path);
|
|
|
|
|
Replay UI support (#15048)
* Add bsv replay controls (not yet fully implemented), remove toggle
see notes in task_movie.c, make sure command.c calls the right
functions, check retroarch.c and other todos.
bsv files are also now stored with states, not saves.
* Compilation fixes
* Added command impls for play and record replay, and some code in load state to do the right thing there
* Guard some parts of the new code with HAVE_BSV_MOVIE
* wip, menu fixes
* more menu fixes, osd for movie errors, halt recording properly
* Menu and label fixes
* move bsvs to own file suffix series under savestates, fix recording and playback command validity checks
* Fix replay autoincrement
* fix endif placement, whoops
---------
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-03-02 23:52:22 +00:00
|
|
|
if (!task || !state || !file_exists)
|
2023-01-25 06:15:32 +00:00
|
|
|
goto error;
|
2023-04-30 17:30:07 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
*state = input_st->bsv_movie_state;
|
2023-01-31 04:34:26 +00:00
|
|
|
strlcpy(state->movie_start_path, path, sizeof(state->movie_start_path));
|
2023-01-25 06:15:32 +00:00
|
|
|
task->type = TASK_TYPE_NONE;
|
|
|
|
task->state = state;
|
|
|
|
task->handler = task_moviectl_playback_handler;
|
|
|
|
task->callback = moviectl_start_playback_cb;
|
|
|
|
task->title = strdup(msg_hash_to_str(MSG_STARTING_MOVIE_PLAYBACK));
|
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
if (task_queue_push(task))
|
|
|
|
return true;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (state)
|
|
|
|
free(state);
|
|
|
|
if (task)
|
|
|
|
free(task);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2023-04-30 17:30:07 +00:00
|
|
|
|
2023-01-25 06:15:32 +00:00
|
|
|
bool movie_start_record(input_driver_state_t *input_st, char*path)
|
|
|
|
{
|
2023-04-30 17:30:07 +00:00
|
|
|
size_t _len;
|
2023-02-21 10:10:25 +00:00
|
|
|
char msg[8192];
|
|
|
|
const char *movie_rec_str = msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO);
|
|
|
|
retro_task_t *task = task_init();
|
2023-04-30 17:30:07 +00:00
|
|
|
moviectl_task_state_t *state = (moviectl_task_state_t *)calloc(1, sizeof(*state));
|
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
if (!task || !state)
|
|
|
|
goto error;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
*state = input_st->bsv_movie_state;
|
|
|
|
strlcpy(state->movie_start_path, path, sizeof(state->movie_start_path));
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-04-30 17:30:07 +00:00
|
|
|
_len = strlcpy(msg, movie_rec_str, sizeof(msg));
|
|
|
|
snprintf(msg + _len, sizeof(msg) - _len, " \"%s\".", path);
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
task->type = TASK_TYPE_NONE;
|
|
|
|
task->state = state;
|
|
|
|
task->handler = task_moviectl_record_handler;
|
|
|
|
task->callback = moviectl_start_record_cb;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
task->title = strdup(msg);
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
if (!task_queue_push(task))
|
|
|
|
goto error;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
2023-02-21 10:10:25 +00:00
|
|
|
return true;
|
2023-01-25 06:15:32 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (state)
|
|
|
|
free(state);
|
|
|
|
if (task)
|
|
|
|
free(task);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|