tLoad and free resources, was reading stale data - spoon - dwm status utility (2f30 fork)
(HTM) git clone git://src.adamsgaard.dk/spoon
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 4981b3a67901a712d52ab9a921cf571232de88c1
(DIR) parent a722598c8613433000b5d3fae11e776ff9f438c2
(HTM) Author: lostd <lostd@2f30.org>
Date: Mon, 7 Nov 2016 12:33:39 +0000
Load and free resources, was reading stale data
Diffstat:
M mix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/mix.c b/mix.c
t@@ -98,12 +98,12 @@ mixread(void *arg, char *buf, size_t len)
warnx("snd_mixer_selem_register: %s", snd_strerror(r));
goto out;
}
+readvol:
r = snd_mixer_load(mixerp);
if (r < 0) {
warnx("snd_mixer_load: %s", snd_strerror(r));
goto out;
}
-readvol:
elem = snd_mixer_find_selem(mixerp, id);
if (elem == NULL) {
warnx("could not find mixer element");
t@@ -130,6 +130,7 @@ readvol:
else
master = 100 * vol / max;
snprintf(buf, len, "%d%%", master);
+ snd_mixer_free(mixerp);
return 0;
out:
snd_mixer_close(mixerp);