瀏覽代碼

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.
Clayton Groeneveld 4 年之前
父節點
當前提交
3e4c2c0535
共有 1 個文件被更改,包括 11 次插入6 次删除
  1. 11 6
      plugins/obs-ffmpeg/obs-ffmpeg-mux.c

+ 11 - 6
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;
 }