Failed to initialize backend "jack"

Sorry if this is a duplicate, I read everything I could in this forum and others, but I cannot find a solution.
I’m on Ubuntu 16.10, fresh install, of 0.9.8, dependencies and codecs installed.
I wrote an app that uses arrays of ofSoundPlayer inside a ofThread and i have the following error:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
AL lib: (WW) ALCjackBackendFactory_init: jack_client_open() failed, 0x11
AL lib: (WW) alc_initconfig: Failed to initialize backend “jack”
Floating point exception (core dumped)

And the app crashes.
It was working until yesterday, then no luck.
What can I do?

This is the list of my audio outputs:
aplay -l
**** Lista di PLAYBACK dispositivi hardware ****
scheda 1: PCH [HDA Intel PCH], dispositivo 0: ALC283 Analog [ALC283 Analog]
Sottoperiferiche: 1/1
Sottoperiferica #0: subdevice #0
scheda 1: PCH [HDA Intel PCH], dispositivo 3: HDMI 0 [HDMI 0]
Sottoperiferiche: 1/1
Sottoperiferica #0: subdevice #0
scheda 1: PCH [HDA Intel PCH], dispositivo 7: HDMI 1 [HDMI 1]
Sottoperiferiche: 1/1
Sottoperiferica #0: subdevice #0
scheda 1: PCH [HDA Intel PCH], dispositivo 8: HDMI 2 [HDMI 2]
Sottoperiferiche: 1/1
Sottoperiferica #0: subdevice #0
(sorry this is in italian)

any clue?
maybe the audio output cannot be determined on boot?
ofSoundPlayer examples seem to work.

i’ve had similar experiences, and usually solved this by pointing ofSoundStream to the right device with something like this at the end of ofApp::setup before initing the audio thread:
soundstream.listDevices();
soundstream.setDeviceID(2);

but if the examples work, and since you mention threading an array of soundplayers, perhaps is thread related?

Thanks for the advice. As you suggested, the problem was in my code, the threading function was running before some audio was loaded, so the crash. Problem solved!
I’ll post the threading class after some cleaning , maybe It could be useful for others too!

I am still digging into this subject, and noticed that also the soundPlayerExample gives me the same error when loading a file for the first time:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
AL lib: (WW) ALCjackBackendFactory_init: jack_client_open() failed, 0x11
AL lib: (WW) alc_initconfig: Failed to initialize backend “jack”

Is this a thing to worry about?
I still have random crashes (just one in 8 hours of app running) when loading new files in already existent players.
I am cleaning my code to post it here for further analysis.
My machine is a UDOOX86 Ultra with an M.2 SSD.

ofSoundPlayer uses OpenAL. It looks like OpenAL attempts to find a Jack server, and reports an error if it doesn’t. It will most likely then proceed to use Alsa for playback I think. You can check this by trying to play system audio while your app is running. If you can’t, that means Alsa has locked the audio hardware. If you can, it’s probably using Pulseaudio.

The ofSoundStream also defaults to Jack at the moment by the way.

Short answer - no, it doesn’t matter. Your crashes are very likely unrelated.

EDIT: Are you using any ofSoundStream objects?

Thank you. I can play other mp3 files with Totem when my app is running, and I am not using any ofSoundStream. Even if I get the above error, the audio file plays (I just get some little noise).
I am done cleaning and commenting my code and I wrote a simple app to test my audioThread.
Here it is as an attachment (no more crashes in the last few hours, but I am not sure they won’t happen again)
When the crash happens, sometimes qtcreator reports an arithmetic exception in ofOpenAlSoundPlayer.cpp line 248: buffer.resize(buffer_size/2);
Another thing I noticed is that when I use mp3s exported from Apple Logic X I get a warning:
Warning: Real sample count 355968 differs from given gapless sample count -1152. Frankenstein stream? Is this something to worry about?
For now I am using just mp3s at 192kb with constant bitrate to make the calculation of the duration easy.
I added 6 mp3s to test: 4 of the mp3s are encoded with ffmpeg, 2 are exported from a Logic X project (EDIT: I noticed just now that I exported 3 mp3s - 01, 03 and 05 - with sample rate 48khz - please remove them).
Hope my code is clear. Maybe it should be posted in programming questions, since I am not sure this is a valid approach to achieve what I need (tracks fading with others and with themselves - the fading is still a bit ugly and not synced).
testAudioThread.zip (1.5 MB)

I tried your app and didn’t get any crashes. Seems to work ok.

The Frankenstein stream error probably only is a problem with trying to achieve gapless playback.

My recommendation is to use Audacity to encode the files as mp3s. Apple products sometimes create weird files or headers. Or even better encode them as .wavs. They’ll take up more disk space but will require less cpu for decoding.

This output is related to Jack. It’s because you have OpenAL-soft compiled with Jack support, and it tries to connect to Jack before anything else. If you disable the Jack backend, this notice will go away:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock

Thank you for your time! I’ll use wav files then. I was using mp3s because they were taking less cpu compared to aif files (the original files I have).
How to disable the Jack backend?

That’s weird, .aiff files are basically like .wavs. Maybe they had something weird in them.

On default Ubuntu 16.04, I don’t have the Jack backend for openal. I had to install it manually to get it…

To get rid of it, run the “alsoft-config” tool and modify the backends there. You may need to install it (it’s a separate package)

When I tried with .aiff files I was still using of 0.8.4, then I took this for granted also now.
The little problem I am facing now with of 0.9.8 is that I cannot start any player with Volume at 0, I tried to set it before loading, after, and after playing. The file starts and just after a little while the volume goes to 0 (and then up with my audioThread fading system).
For now I’ll add some silence at the start of files as a workaround, but I’d like to know if also others face this issue.
EDIT: I cannot find alsoft-config, what is the name of the package?

Sorry it’s called alsoft-conf

sudo apt install alsoft-conf

The volume should work immediately, provided your files have been loaded. This is the underlying code (in openFrameworks->lib->openFrameworks->sound->ofOpenALSoundPlayer.cpp:

void ofOpenALSoundPlayer::setVolume(float vol){
	volume = vol;
	if(sources.empty()) return;
	if(channels==1){
		alSourcef (sources[sources.size()-1], AL_GAIN, vol);
	}else{
		setPan(pan);
	}
}

If volume is not working it’s probably because your files haven’t finished loading. It’s this line that actually counts:

alSourcef (sources[sources.size()-1], AL_GAIN, vol);

but it doesn’t get called if sources is empty, i.e. there is no loaded sample.

Thanks, and sorry for the late reply.
The software has been working for 12+ hours without crashes with wav files. The problem of the volume is still there.
I will do other tests in the next days, and report here my results.

I did some other tests. The volume problem I had was caused by the fade calculation: I was using a log fade, instead of an exponential one. So the volume was rising too fast. I posted a new version of the audioThread in this post, since most of the code I am using comes from there.
[Here is a link to the new project] (https://forum.openframeworks.cc/uploads/default/original/2X/5/50297a11e363ca1c1bd3f6bf9cc15f26f44406e8.zip) (1.7 MB).
Thanks everybody for helping me!

Hi everybody,

I’ve the same warning about JACK on Ubuntu 18.04 with OF 0.11 (of_v20190324_linux64gcc6_release) - The audioInputExample works perfectly (as all my apps with same features) , but I have these warnings:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

I don’t have the JACK backend in the list of the backends in the OpenAL Configuration Utility, so I cannot remove it as grimus suggest.

Do I have fix this issue anyway or can I safely use my applications in public events (where everything must run fine)?

thanks in advance,

Paolo

Hi Paolo,
I didn’t have the chance to try OF 0.11, so I cannot say if this warning can lead into problems.
In OF 0.9.8 the problems I had were unrelated to that error message.

Hi giovannibedetti,

Thanks for your answer,

I know your issue was not related with this console messages. I hope someone else has had a similar issue. Linux is widely used for long time running applications, but in our community there is a lack of specific documentation on major malfunctioning on Linux.

Ciao,

Paolo