ges: launch: Fix usage of save-only after loading a project

We need to wait for the project to be loaded before saving the file
and quit

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4003

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7882>
This commit is contained in:
Thibault Saunier 2024-11-13 18:18:30 -03:00 committed by GStreamer Marge Bot
parent 6ba70f5da8
commit c00429a917
2 changed files with 25 additions and 8 deletions

View file

@ -880,14 +880,15 @@ _project_loaded_cb (GESProject * project, GESTimeline * timeline,
GESLauncherParsedOptions *opts = &self->priv->parsed_options;
GST_INFO ("Project loaded, playing it");
if (opts->save_path) {
if (opts->save_path || opts->save_only_path) {
gchar *uri;
GError *error = NULL;
gchar *save_path = opts->save_path ? opts->save_path : opts->save_only_path;
if (g_strcmp0 (opts->save_path, "+r") == 0) {
uri = ges_project_get_uri (project);
} else if (!(uri = ensure_uri (opts->save_path))) {
g_error ("couldn't create uri for '%s", opts->save_path);
} else if (!(uri = ensure_uri (save_path))) {
g_error ("couldn't create uri for '%s", save_path);
self->priv->seenerrors = TRUE;
g_application_quit (G_APPLICATION (self));
@ -903,6 +904,12 @@ _project_loaded_cb (GESProject * project, GESTimeline * timeline,
g_error_free (error);
g_application_quit (G_APPLICATION (self));
}
if (opts->save_only_path) {
g_application_quit (G_APPLICATION (self));
return;
}
}
project_uri = ges_project_get_uri (project);
@ -1715,8 +1722,12 @@ _startup (GApplication * application)
if (!_create_pipeline (self, opts->sanitized_timeline))
goto failure;
if (opts->save_only_path)
if (opts->save_only_path) {
if (opts->load_path) {
g_application_hold (G_APPLICATION (self));
}
goto done;
}
if (!_set_playback_details (self))
goto failure;

View file

@ -130,6 +130,7 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher,
g_object_set_data (G_OBJECT (pipeline), "pposition-id",
GUINT_TO_POINTER (g_timeout_add (200,
(GSourceFunc) _print_position, pipeline)));
return TRUE;
}
@ -214,11 +215,16 @@ ges_validate_clean (GstPipeline * pipeline)
GstValidateRunner *runner =
g_object_get_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE);
if (runner)
if (runner) {
res = gst_validate_runner_exit (runner, TRUE);
else
g_source_remove (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pipeline),
"pposition-id")));
} else {
gpointer pposition =
g_object_get_data (G_OBJECT (pipeline), "pposition-id");
if (pposition) {
g_source_remove (GPOINTER_TO_INT (pposition));
}
}
gst_object_unref (pipeline);
if (runner)