From 7ca1843dec7c9af92c289ae401e9054f5bd79f3d Mon Sep 17 00:00:00 2001 From: sparkelpotato Date: Wed, 25 Jun 2025 01:09:18 -0500 Subject: [PATCH] lock user-set volume with --alsa-volume as well Makes sure the ALSA volume doesn't get messed with if --volume and --alsa-volume are both passed as args. This makes sure the user-set volume stays preserved regardless of commands passed to espeakup. --- src/espeak.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/espeak.c b/src/espeak.c index 747e15e..aeaac74 100644 --- a/src/espeak.c +++ b/src/espeak.c @@ -204,6 +204,10 @@ static void set_alsa_volume(int vol) * 100%. */ int volume = (vol + 1) * 50 / 10 + 50; + /*lock the volume to the user-set volume if specified*/ + if(volumeSet){ + volume = defaultVolume; + } for (e = snd_mixer_first_elem(m); e; e = snd_mixer_elem_next(e)) { if (snd_mixer_elem_get_type(e) != SND_MIXER_ELEM_SIMPLE) @@ -253,7 +257,7 @@ static espeak_ERROR set_volume(struct synth_t *s, int vol, enum adjust_t adj) if (adj != ADJ_SET) vol += s->volume; - /* use the volume if specified by the user */ + /*lock the volume to the user-set volume if specified*/ if (volumeSet) { rc = espeak_SetParameter(espeakVOLUME, defaultVolume, 0); }