pidgin/pidgin

Set volume on audio test pipeline at startup
gtk4
21 months ago, Elliott Sales de Andrade
4be49932c288
Set volume on audio test pipeline at startup

If you change the volume slider in prefs, then the Test Audio button does not respect that initially. If you move the slider around with the test playing, then the volume jumps to whatever you have. But stopping and starting the test again goes to full volume.

Testing Done:
Opened prefs, set to test source, made volume really low, and hit Test Audio. Output volume was low immediately.

Reviewed at https://reviews.imfreedom.org/r/1670/
--- a/pidgin/prefs/pidginvvprefs.c Sun Aug 28 04:45:49 2022 -0500
+++ b/pidgin/prefs/pidginvvprefs.c Sun Aug 28 21:53:47 2022 -0500
@@ -104,7 +104,7 @@
}
static GstElement *
-create_voice_pipeline(void)
+create_voice_pipeline(PidginVVPrefs *prefs)
{
GstElement *pipeline;
GstElement *src, *sink;
@@ -120,6 +120,10 @@
level = gst_element_factory_make("level", "level");
valve = gst_element_factory_make("valve", "valve");
+ g_object_set(volume, "volume",
+ gtk_scale_button_get_value(GTK_SCALE_BUTTON(prefs->voice.volume)) / 100.0,
+ NULL);
+
gst_bin_add_many(GST_BIN(pipeline), src, volume, level, valve, sink, NULL);
gst_element_link_many(src, volume, level, valve, sink, NULL);
@@ -218,7 +222,7 @@
{
GstBus *bus;
- prefs->voice.pipeline = create_voice_pipeline();
+ prefs->voice.pipeline = create_voice_pipeline(prefs);
bus = gst_pipeline_get_bus(GST_PIPELINE(prefs->voice.pipeline));
gst_bus_add_signal_watch(bus);
g_signal_connect(bus, "message", G_CALLBACK(gst_bus_cb), prefs);