From 1001fda2560a94411c9bf699e0d730b824c4f5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 3 May 2024 17:18:17 +0200 Subject: [PATCH] clapper-app: Add command line option to set volume --- src/bin/clapper-app/clapper-app-application.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index d983aaac..fccda1cc 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -60,6 +60,8 @@ struct ClapperPluginData struct ClapperAppOptions { + gdouble volume; + gchar *video_filter; gchar *audio_filter; @@ -264,7 +266,12 @@ _restore_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_ if (app_opts.audio_sink) clapper_player_set_audio_sink (player, clapper_app_utils_make_element (app_opts.audio_sink)); - clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); + /* NOTE: Not using ternary operator to avoid accidental typecasting */ + if (app_opts.volume >= 0) + clapper_player_set_volume (player, PERCENTAGE_ROUND (app_opts.volume)); + else + clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); + clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); clapper_player_set_subtitles_enabled (player, g_settings_get_boolean (self->settings, "subtitles-enabled")); @@ -533,6 +540,8 @@ clapper_app_application_open (GApplication *app, static void clapper_app_application_init (ClapperAppApplication *self) { + app_opts.volume = -1; + self->need_init_state = TRUE; } @@ -544,6 +553,7 @@ clapper_app_application_constructed (GObject *object) guint i; const GOptionEntry app_options[] = { + { "volume", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.volume, _("Audio volume to set (0 - 2.0 range)"), NULL }, { "video-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_filter, _("Video filter to use (\"none\" to disable)"), NULL }, { "audio-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_filter, _("Audio filter to use (\"none\" to disable)"), NULL }, { "video-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_sink, _("Video sink to use"), NULL },