Преглед на файлове

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;
 			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;
 		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)
 static void *replay_buffer_mux_thread(void *data)
 {
 {
 	struct ffmpeg_muxer *stream = data;
 	struct ffmpeg_muxer *stream = data;
+	bool error = false;
 
 
 	start_pipe(stream, stream->path.array);
 	start_pipe(stream, stream->path.array);
 
 
 	if (!stream->pipe) {
 	if (!stream->pipe) {
 		warn("Failed to create process pipe");
 		warn("Failed to create process pipe");
+		error = true;
 		goto error;
 		goto error;
 	}
 	}
 
 
 	if (!send_headers(stream)) {
 	if (!send_headers(stream)) {
 		warn("Could not write headers for file '%s'",
 		warn("Could not write headers for file '%s'",
 		     stream->path.array);
 		     stream->path.array);
+		error = true;
 		goto error;
 		goto error;
 	}
 	}
 
 
@@ -847,6 +844,14 @@ error:
 	stream->pipe = NULL;
 	stream->pipe = NULL;
 	da_free(stream->mux_packets);
 	da_free(stream->mux_packets);
 	os_atomic_set_bool(&stream->muxing, false);
 	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;
 	return NULL;
 }
 }