From 335b8a2567eff46169a37011849870c9f2c2cc3b Mon Sep 17 00:00:00 2001 From: lawl Date: Thu, 4 Feb 2021 10:41:16 +0100 Subject: [PATCH] Fix unloading via CLI (-u) Squashed commit of the following: commit 19532d64a7f7337da7f844d52198417ceaf60e80 Author: lawl Date: Thu Feb 4 10:40:27 2021 +0100 Fix unloading paClient for UI commit 66ece81e17589988f92059b44b2659fdca0c4ca1 Merge: 1c97cfe 60d06f2 Author: lawl Date: Thu Feb 4 10:36:13 2021 +0100 Merge branch 'fix_cli_unload' of git://github.com/hador/NoiseTorch into hador-fix_cli_unload commit 60d06f25aacc78fe3f0c8174ab8f6bf4610314eb Author: andreafa Date: Thu Feb 4 08:51:48 2021 +0000 Fix cli unload (-u). The findModule method in module.go requires a valid paClient to be populated in the context object. Added logging if unloadSupressor fails when called via the -u CLI flag. --- main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c3ccf11..706e0a7 100644 --- a/main.go +++ b/main.go @@ -107,6 +107,8 @@ func main() { os.Exit(1) } + ctx.paClient = paClient + if list { fmt.Println("Sources:") sources := getSources(paClient) @@ -133,12 +135,15 @@ func main() { } if unload { - unloadSupressor(&ctx) + err := unloadSupressor(&ctx) + if err != nil { + fmt.Fprintf(os.Stderr, "Error unloading PulseAudio Module: %+v\n", err) + os.Exit(1) + } os.Exit(0) } if loadInput { - ctx.paClient = paClient sources := getSources(paClient) if sinkName == "" { @@ -165,7 +170,6 @@ func main() { } if loadOutput { - ctx.paClient = paClient sinks := getSinks(paClient) if sinkName == "" { @@ -192,6 +196,9 @@ func main() { } + ctx.paClient.Close() + ctx.paClient = nil + if ctx.config.EnableUpdates { go updateCheck(&ctx) }