aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlawl <github@dumbinter.net>2021-02-04 10:41:16 +0100
committerlawl <github@dumbinter.net>2021-02-04 10:41:16 +0100
commit335b8a2567eff46169a37011849870c9f2c2cc3b (patch)
tree1e7c456a00fb30ec5a237a4c664a501b86e2ce73
parent1c97cfe43cb6bdaa0b99d61418d31019e52cd9da (diff)
downloadnoisetorch-335b8a2567eff46169a37011849870c9f2c2cc3b.tar.gz
noisetorch-335b8a2567eff46169a37011849870c9f2c2cc3b.zip
Fix unloading via CLI (-u)
Squashed commit of the following: commit 19532d64a7f7337da7f844d52198417ceaf60e80 Author: lawl <github@dumbinter.net> Date: Thu Feb 4 10:40:27 2021 +0100 Fix unloading paClient for UI commit 66ece81e17589988f92059b44b2659fdca0c4ca1 Merge: 1c97cfe 60d06f2 Author: lawl <github@dumbinter.net> 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 <andreafa@amazon.com> 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.
-rw-r--r--main.go13
1 files 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)
}