diff --git a/src/main.c b/src/main.c index 3b54f32..0ef3176 100644 --- a/src/main.c +++ b/src/main.c @@ -1008,13 +1008,11 @@ flash_button_clicked(GtkWidget *button, gpointer user_data) } void -notify_movie_progress(void) +notify_movie_record_ready(void) { - if (!movie_start) { - // Recording started - gtk_button_set_icon_name(GTK_BUTTON(movie), - "video-recording-symbolic"); - } + movie_start = 0; + gtk_button_set_icon_name(GTK_BUTTON(movie), + "video-inactive-symbolic"); } void diff --git a/src/main.h b/src/main.h index df6ef82..2af2584 100644 --- a/src/main.h +++ b/src/main.h @@ -38,7 +38,7 @@ int remap(int value, int input_min, int input_max, int output_min, int output_ma bool check_window_active(); -void notify_movie_progress(void); +void notify_movie_record_ready(void); void notify_movie_message(gchar *msg); void notify_auto_status(gchar *msg); diff --git a/src/process_pipeline.c b/src/process_pipeline.c index 70424de..e50d806 100644 --- a/src/process_pipeline.c +++ b/src/process_pipeline.c @@ -837,7 +837,6 @@ static void on_read_complete(GObject *source_object, GAsyncResult *res, gpointer // End of file reached, close the stream g_input_stream_close(stream, NULL, NULL); g_object_unref(stream); - notify_movie_progress(); return; } if (bytes_read < 0) { @@ -868,6 +867,27 @@ static void on_read_complete(GObject *source_object, GAsyncResult *res, gpointer on_read_complete, NULL); } +static void +spawn_movie_finished(GSubprocess *proc, GAsyncResult *res, gpointer data) +{ + int exit_status; + + g_subprocess_wait_finish(proc, res, NULL); + if (g_subprocess_get_if_exited (proc)) { + exit_status = g_subprocess_get_exit_status (proc); + if (movie_recording) { + // stop recording, when recording failed to start + if (exit_status) { + movie_recording = 0; + notify_movie_record_ready(); + } + } else { + // finished video processing + notify_movie_record_ready(); + } + } +} + static void spawn_movie(char *cmd) { @@ -910,6 +930,8 @@ spawn_movie(char *cmd) // Read the output of the subprocess asynchronously g_input_stream_read_async(stdout_stream, stdout_buf, sizeof(stdout_buf), G_PRIORITY_DEFAULT, NULL, on_read_complete, NULL); + + g_subprocess_wait_async(proc, NULL, (GAsyncReadyCallback)spawn_movie_finished, NULL); }