Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoiseTorch does not start #178

Closed
dolwup opened this issue Sep 27, 2021 · 5 comments
Closed

NoiseTorch does not start #178

dolwup opened this issue Sep 27, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@dolwup
Copy link

dolwup commented Sep 27, 2021

When I start NoiseTorch from CLI it just throws an error and does not start. I can however start the noise supression with noisetorch -i and can in general interact with NoiseTorch through command line. I am running PipeWire on Arch. NoiseTorch works completely fine on my laptop (also PW on Arch).

The output of attempting to start noisetorch:

panic: runtime error: slice bounds out of range [:1025] with capacity 1024

goroutine 18 [running]:
github.com/lawl/pulseaudio.bread(0x8953e0, 0xc00009c2d0, 0xc0002ada28, 0x9, 0x9, 0x0, 0x0)
	/home/user/code/NoiseTorch/vendor/github.com/lawl/pulseaudio/format.go:162 +0xd9e
github.com/lawl/pulseaudio.(*Module).ReadFrom(0xc0000a8540, 0x8953e0, 0xc00009c2d0, 0x7f5398873110, 0xc0000a8540, 0x1)
	/home/user/code/NoiseTorch/vendor/github.com/lawl/pulseaudio/module.go:16 +0x145
github.com/lawl/pulseaudio.bread(0x8953e0, 0xc00009c2d0, 0xc0001adc88, 0x1, 0x1, 0x0, 0x0)
	/home/user/code/NoiseTorch/vendor/github.com/lawl/pulseaudio/format.go:220 +0xa09
github.com/lawl/pulseaudio.(*Client).ModuleList(0xc0002841b0, 0xc000298240, 0xc000070d80, 0xc0002addc0, 0xc0002add50, 0x3)
	/home/user/code/NoiseTorch/vendor/github.com/lawl/pulseaudio/module.go:38 +0x12d
main.findModule(0xc0002841b0, 0x810589, 0x14, 0x8176c5, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/user/code/NoiseTorch/module.go:440 +0x67
main.supressorState(0xc000178000, 0x23, 0xc00004c7a8)
	/home/user/code/NoiseTorch/module.go:43 +0xc5
main.updateNoiseSupressorLoaded(0xc000178000)
	/home/user/code/NoiseTorch/module.go:27 +0x165
created by main.paConnectionWatchdog
	/home/user/code/NoiseTorch/main.go:202 +0x3a5

I also ran pw-cli dump to get some more information

@lawl lawl added the bug Something isn't working label Sep 27, 2021
@lawl
Copy link
Contributor

lawl commented Sep 27, 2021

buf := make([]byte, 1024) // max string length i guess.

https://github.com/lawl/pulseaudio/blob/cb2596d6a8ef0c59cf1177fac851001f7220644e/format.go#L159

Someone guessed wrong, I guess. Probably the

pipewire.sec.label = "hex:e0cbbd8efd7f[snip lots of hex]527f0000"

tripping us up.

@lawl
Copy link
Contributor

lawl commented Sep 27, 2021

Do you have the ability to build from source and patch this line to buf := make([]byte, 4096). Just to confirm that's actually the issue? Otherwise, if you trust my binaries, I can make you a build with that.

Will still need to figure out a proper fix later.

@dolwup
Copy link
Author

dolwup commented Sep 27, 2021

I changed the line you mentioned and this indeed fixes the issue.

@lawl
Copy link
Contributor

lawl commented Sep 28, 2021

diff --git a/format.go b/format.go
index f1e7503..51b52c8 100644
--- a/format.go
+++ b/format.go
@@ -156,13 +156,15 @@ func bread(r io.Reader, data ...interface{}) error {
 
                sptr, ok := v.(*string)
                if ok {
-                       buf := make([]byte, 1024) // max string length i guess.
+                       buf := make([]byte, 0)
                        i := 0
                        for {
-                               _, err := r.Read(buf[i : i+1])
+                               var curChar [1]byte
+                               _, err := r.Read(curChar[:])
                                if err != nil {
                                        return err
                                }
+                               buf = append(buf, curChar[0])
                                if buf[i] == 0 {
                                        *sptr = string(buf[:i])
                                        break

@lawl
Copy link
Contributor

lawl commented Sep 28, 2021

oops. sent too early accidentally. Could you try with this more proper patch again?

@lawl lawl closed this as completed in 4aca9e6 Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants