xthexder / go-jack

Go bindings for Jack Audio Connection Kit
MIT License
75 stars 22 forks source link

Example code frequently fails with error "SuspendRefNum" #22

Open hicks927 opened 3 years ago

hicks927 commented 3 years ago

I've been trying to use this library for a small project, but upon investigating issues with my code, I noticed that it, and the pass-through example code for this library both fail on approximately 9/10 executions with the error:

SuspendRefNum error
JackClient::Execute error name = AudioStreamer

I've tried quite a number of workarounds, jackd settings and even a different computer (both running close to stock ubuntu studio). Does anyone have any ideas of what the cause may be? I'm utterly perplexed that sometimes it will just work fine.

sirjohndfox commented 3 years ago

@hicks927 Gday mate, I got annoyed at this state of affairs too (again). I'm not an expert programmer by any means, nor even a competent one - but I've come up with a fairly dirty hack. However you'll need to recompile jackd. I found out by dropping some judicious print statements the failure occurs in JackClient.cpp around line 636:

---636-- inline bool JackClient::WaitSync() { // Suspend itself: wait on the input synchro if (GetGraphManager()->SuspendRefNum(GetClientControl(), fSynchroTable, 0x7FFFFFFF) < 0) { jack_error("SuspendRefNum error"); //Dirty Hack for golang bindings. was false return true; } else { return true; } }

I just toggled the return value to ignore the error. I'd like to eventually know WTF is going on and why but now my go client starts everytime and I've not noticed any adverse effects. The python bindings work fine so I think there shpuld really be no trouble for golang. I wish I could understand the code well enough to fix it properly.

Anyway thought you might be interested.

bhechinger commented 3 years ago

I'm getting a similar issue as well. I'm trying to capture midi events. I've taken the example passthrough code and instead of sending the events back out I just print them. I get this error also 9/10 times but that 1 time I don't get this error I get a segfault. I really wanted to not write this in python, but I'm not seeing that I have any options at this point. :(

bhechinger commented 3 years ago

Oh, I found #13 so that's the segfault dealt with. Now I get the SuspendRefNum error every run.

sirjohndfox commented 3 years ago

I've got a feeling it's something to do with the blocking configuration of the channels. I'd been keen to know if the original author ever had this working...

mickmister commented 1 year ago

@sirjohndfox It would be great to have a proper fix, rather than the workaround above, which seems to be working great. Thank you so much.

I need to compile Jack myself now, though thankfully they have a GitHub Actions pipeline that made this straightforward. https://github.com/jamtools/jack2/pull/1

I'm partially leaving this comment here for documentation, but also to discuss the cause or a solution to this issue. I have no idea what I'm doing with this code so I probably won't be much help debugging this, but I love using this library. Thanks to anyone that wants to investigate this.