From 3e4c2c0535154d823149acdaa8b4c501ecac2556 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Thu, 4 Feb 2021 11:02:35 -0600 Subject: [PATCH] obs-ffmpeg: Fix replay save callback not working properly Previously the save callback would be called when the replay buffer hotkey was pressed and not when the saving of the replay was finished. When the 'get_last_replay' procedure was called after the saved callback function, it would return the incorrect path, as the path would still be the previous path. --- plugins/obs-ffmpeg/obs-ffmpeg-mux.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c index 83f04b64a..cba35e651 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c @@ -650,12 +650,6 @@ static void replay_buffer_hotkey(void *data, obs_hotkey_id id, return; } - calldata_t cd = {0}; - - signal_handler_t *sh = - obs_output_get_signal_handler(stream->output); - signal_handler_signal(sh, "saved", &cd); - stream->save_ts = os_gettime_ns() / 1000LL; } } @@ -820,17 +814,20 @@ static void insert_packet(struct darray *array, struct encoder_packet *packet, static void *replay_buffer_mux_thread(void *data) { struct ffmpeg_muxer *stream = data; + bool error = false; start_pipe(stream, stream->path.array); if (!stream->pipe) { warn("Failed to create process pipe"); + error = true; goto error; } if (!send_headers(stream)) { warn("Could not write headers for file '%s'", stream->path.array); + error = true; goto error; } @@ -847,6 +844,14 @@ error: stream->pipe = NULL; da_free(stream->mux_packets); os_atomic_set_bool(&stream->muxing, false); + + if (!error) { + calldata_t cd = {0}; + signal_handler_t *sh = + obs_output_get_signal_handler(stream->output); + signal_handler_signal(sh, "saved", &cd); + } + return NULL; }