Audio-related crash: "Desired audio parameters for device -1 unsupported by audio device: Illegal combination of I/O devices"

MVDPSWVZ-20233722233:8e728b4166a96bd3a343654e87f74deedc80045367d4a096af3fec222311b01a

Dear support team, dear Mario,

We are experiencing a psychtoolbox error that we have never experienced before on any of our setups. Today we have installed a brand new experimental setup, using Ubuntu 22.04.2 (normal kernel, X11), Matlab 2022b, and psychtoolbox installed via neurodebian. We followed the exact installation instructions and have also run the PsychLinuxConfiguration. All demos, GarboriumDemo and the like, run beautifully and with good timing.

We then proceeded to check the Eyelink setup and tested it with EyelinkExample - the link opens, we get the right callback, but once we start running a calibration or drift correction, psychtoolbox screen crashes, basically upon “Initializing PsychPortAudio driver for sound output” (please see the first photo attached). In fact, the screen displayed correctly but it seemed as if the beeps that are presented along with the calibration markers caused the crash. The error is not systematic either, that is, it might occur upon the 3rd or 4th beep, but (after one finally aborts the calibration on the Eyelink host) it always results in the same errors “Desired audio parameters for device -1 unsupported by audio device: Illegal combination of I/O devices” and following lines. We could get similar errors when running PsychPortAudioTimingTest, so we assume it’s not necessarily related to the Eyelink routines.

We first checked whether the problem is the Eyelink itself or the system sound: We tried SR Research’s Track program, which also performs a calibration with sounds, and it ran without any trouble. Furthermore, sound generally works, system sound tests work and alsamixer is displaying things as one would expect. In the terminal we found error messages relating to the jack server and server socket errors (please see second photo attached), but googling these jack-related error did not reveal any results directly relatable to our problem.

As the problem is brand new, we haven’t been able to do much debugging, but - quite honestly - we would not know where to start. Do you recognize these errors or know how they are caused? Could you please give us some advice on what to try next? We’d appreciate it a lot.

This new setup is critical at the moment, and we’d love to have it up and running as soon as possible. Thanks so much in advance.

Martin.

Hi Martin

Hmm, nicely written bug report. Unfortunately i already spent 2 hours of work on this so far, while your license only paid for the first 30 minutes. And the problem is a non-trivial to diagnose bug somewhere, obviously. I was generous with time as a thank you for your financial support of PTB in the past, but obviously this can not extend arbitrarily. Unfortunately supportive users like you are the absolute exception, over 99% of our users are just irrationally short-sighted enough to decide to free-ride, so we can not afford to be generous with my time anymore, given the serious financial situation.

So lets try to find workarounds instead of solutions, so you are not left empty handed:

It sounds to me as if this might be some kind of problem related to frequent opening and closing and reopening the soundcard. PsychPortAudio takes exclusive control of a soundcard for high timing precision and control, as opposed to most common sound software, which may or may not trigger some bugs in some sound chips drivers if this a rather new machine or sound chip whose software might not be as mature yet.

Eyelink uses Beeper which opens the device, beeps, then closes the device for each single tone, ie. lots of repeated open → close → open …, maybe that’s why failure is non-deterministic.

Does PsychPortAudioTimingTest also show this behaviour of sometimes working, but then failing on repeated execution?

For completeness:

What is the brand/model of this machine?
What is the output of PsychPortAudio('Verbosity', 10); PsychPortAudioTimingTest?
What is the output of alsa-info in a terminal window, ie. the content of the written log file by that command?

For possible workarounds:

Do you need the feedback tones during Eyelink operation?

If not, you can simply set el.targetbeep=0 and el.feedbackbeep=0 after EyelinkInitDefaults() to get rid of sound output, as described in help EyelinkDoTrackerSetup and other locations.

Or you could keep the audio device open by following the instructions in the section “Audio device sharing for interop with PsychPortAudio” in help Snd for Eyelink, Beeper, and Snd use.

Or you could read help Snd in the section about “Snd_use_oldstyle.txt” on how to let Eyelink/Beeper/Snd use Matlabs old sound() function for sound output in these cases, which is pretty shoddy, but would avoid problems related to PsychPortAudio on your machine, in exchange for potential problems caused by Matlabs sound() function.

Do you need PsychPortAudio sound for your experiments on that machine?

If yes, and if nothing obviously jumps into my mind after reading all the debug output i asked here, we could continue debugging, but only if you buy extra paid support hours. I will provide you with instructions for buying these discounted hours if you choose so. Currently you are eligible to a 10% discount on the price of 300 Euros per started hour, iow. 270 Euros + VAT/Mwst for each started hour.

Or a different sound card could be tried, circumventing potential driver bugs for your builtin sound chip.

-mario

[2 hours of 30 minutes paid time used. Paid support completely exhausted.]

Hello,

I would like to report the same problem that martin.rolfs has reported above.
The audio part on Psychtoolbox scripts is not working.
I tried

  • old scripts of mine that were working 100%
  • your tutorial that I found here: beepDemoCode
  • the command PsychPortAudioTimingTest

I always get the same error (here below is the result from PsychPortAudioTimingTest):

PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Illegal combination of I/O devices
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
PTB-ERROR: On Linux you may be able to use ALSA audio converter plugins to make this work.
Error in function Open:         Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
error: PsychPortAudio: Usage:

pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);
error: called from
    PsychPortAudioTimingTest at line 161 column 10

Please find attached a screenshot where you see the error report from (1) running my script “pauseExp_discrTask(1, ‘discr_sequences.mat’, 1)” and (2) the PsychPortAudioTimingTest.

Thank you in advance for your time.

Working for me on Ubuntu 22.04 + PTB 3.0.19 with built-in audio of a Dell workstation. Have you tried to select another audio device?

@vtsogli feedback with Octave suggests it is at least this time not a Matlab induced problem this time, assuming this report is caused by the same root cause and not just similar. Matlab since a while decided to ship their own portaudio library, overriding the system provided one, to make life more difficult, because Mathworks…

Ian, what’s your output when running? Ie. what’s the content of the “choosing deviceIndex 0 …” line? What Linux kernel version?

My suspicion is that this might be a low level audio driver bug, specific to “HDA Intel PCH: ALC 298 Analog” or similar common onboard Intel audio chips.

But then it seems to happen always for @vtsogli but only sometimes or on repeated use for Martin.

My MS Surface Pro 6 tablet/laptop has the same audio hw as @vtsogli but will run on Ubuntu 20.04 for a while longer, with a custom Linux 5.16.11-surface kernel, so testing is work.

Anyhow, I need Martin’s feedback and the infos i requested. And payment for further investigations from Martin or @vtsogli. As stated many times before, we aren’t a charity and can’t continue to act like one if PTB and all the toolboxes that depend on it (including Python based ones) are supposed to have a future.

Financial loss for the PTB project so far: 600 Euros in billable time. I really have to be more strict.
-mario

Hello Ian-Max-Andolina,

Thank you for your suggestion. I tried to use another device in the followng way:

pahandle = PsychPortAudio('Open', [,7], [], 0, smpRte, 2);

instead of this:

pahandle = PsychPortAudio('Open', [], [], 0, smpRte, 2);

but with no success.

This is the point where you have to provide all the information I also asked from Martin, who actually paid for support, and also provide proof of purchase of a paid support membership yourself for up to 30 minutes of my work time. And be prepared that 30 minutes won’t be enough and things get expensive if you want them resolved, unless your information gives me some quick insight.

If our users generally would be more supportive, debugging and fixing such issues would simply be paid for from the general funds, but with stingy or lazy users like ours making up over 99% of the “community”, this is no longer an option and whoever has the problem gets the big bill, or gets to keep their problem. Unfortunately our 2+ years informal study with a sample size of n=multiple ten-thousand users suggests that brain scientists in general don’t seem to have very well working brains when it comes to rational behavior or long-term thinking, it is more like “penny wise, pound foolish”. And this is why we can’t have nice things…

-mario

Thanks, Mario, for spending this much time on the issue. It is really appreciated. We will get back to you on Monday with the requested tests and information.

For now, we might disable PsychPortAudio-based sound because we don’t necessarily need it right now. We are running this machine in combination with a Datapixx (VPixx), which is likely the better choice for low-latency sound stimuli. We might also try a separate sound card and post updates here.

Thanks,
Martin.

PS: @Everyone else: If your lab can at all afford support for Psychtoobox (if you’re not the PI, talk to them!), please do so. It has never been easier: psychtoolbox.net

PTB-INFO: Using PortAudio V19.7.0-devel, revision 147dd722548358763a8b649b3e4b41dfffbcfbb6
PTB-INFO: Choosing deviceIndex 0 [HDA Intel PCH: ALC3234 Analog (hw:0,0)] as default output audio device.
PTB-INFO: New audio device -1 with handle 0 opened as PortAudio stream:
PTB-INFO: For 2 channels Playback: Audio subsystem is ALSA, Audio device name is HDA Intel PCH: ALC3234 Analog (hw:0,0)
PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000 msecs, Output latency 9.977324 msecs.

PTB-INFO: This is Psychtoolbox-3 for GNU/Linux X11, under Matlab 64-Bit (Version 3.0.19 - Build date: Feb 19 2023).
PTB-INFO: OS support status: Linux 6.2.1-060201-generic Supported.
>> d = PsychPortAudio('GetDevices');
>> d(1)

ans = 

  struct with fields:

          DeviceIndex: 0
       HostAudioAPIId: 8
     HostAudioAPIName: 'ALSA'
           DeviceName: 'HDA Intel PCH: ALC3234 Analog (hw:0,0)'
      NrInputChannels: 2
     NrOutputChannels: 2
      LowInputLatency: 0.0087
     HighInputLatency: 0.0348
     LowOutputLatency: 0.0087
    HighOutputLatency: 0.0348
    DefaultSampleRate: 44100

Ubuntu 22.04 using 6.2.1-060201-generic (from mainline ppa, but I also use 5.19 [HWE for 22.04.02] lowlatency and didn’t see an error IIRC)…

Thanks Ian. So I tested this now as well, with both Linux 6.2 on Ubuntu 20.04.5 and then with the current Ubuntu 22.04.2-LTS live image with Linux 5.19 HWE, on the same type of sound chip as @vtsogli and nope, it is not a Linux kernel / sound driver bug or regression, neither a problem with Ubuntu 22.04.2 per se. Everything works perfectly fine on the Intel HDA ALC 298, Beeper, Snd, PsychPortAudioTimingTest etc., GStreamer movies with sound, regular system sounds. There goes another half Sunday…

As far as I’m concerned @vtsogli problem is not something widespread affecting myself or expected to affect many other people. And possibly unrelated to Martin’s problem. So case closed, as far as free support is concerned.

That leaves us with zero suspects for what is causing this, except that it must be something odd or exotic, and paid support would be needed to look further into it.

Dear Mario,
thanks again for the time you have invested in this. Only today we got the chance work on the setup again.

For completeness, attached to this you’ll find output of the verbose PsychPortAudioTimingTest. I also wanted to attach the alsa-info, but it’s too long and I got this:

An error occurred: Body is limited to 32000 characters; you entered 84098

Let me know if you have a work around to post a txt-file here or if I should send it by email.

The first run of PsychPortAudioTimingTest ran without trouble but for the second run (maybe unrelated, but headphones were attached) we received the reported error messages again. So, yes, the script also showed a sometimes-working behavior, but it always failed upon the first beep or completed all beeps without trouble.

Your workaround following “Audio device sharing for interop with PsychPortAudio” for Snd works - so you’re right, the problem seems to be related to Eyelink using Beeper to frequently open and close the device - keeping it open solved the issue completely. Thus, we did not try anymore turning off sounds in EyelinkInitDefaults, plus our RAs like the beeping sounds. Also, we don’t need PsychPortAudio because we can, luckily, use our Datapixx for presenting sound stimuli.

That said, Ubuntu 22.04 proved extremely buggy with a few other features. For instance, we could not get Matlab’s VideoReader (which we desperately need) to run, as somehow gstreamer plugins were broken. After exhausting the time that could be spent on debugging, we installed Ubuntu 20.04 on the machine - which solved all the issues presented above, even when not using the workaround you proposed. Interestingly though, the jack-related messages in the terminal remained, but crashes during calibration were completely avoided. We are aware that 20.04 will not be around forever and might therefore not be the ideal solution to go with, but for now we have to prioritize having a working setup capable of collecting data.

Thanks so much once more for your help, and please let us know if we can still provide some info useful to solving these issues.

Cheers,
Martin.

############################## RUN 1 ################################


>> PsychPortAudio('Verbosity', 10); PsychPortAudioTimingTest
Will test accuracy of scheduled sound onset, i.e. how well the driver manages to
emit sound at exactly the specified "when" deadline. Sound should start in exact
sync with display black-white transition (or at least very close - < 1 msec off).
The remaining bias can be corrected by providing the bias as "latbias" parameter
to this script. Variance of sound onset between trials should be very low, much
smaller than 1 millisecond on a well working system.

Will use auto-selected default output device. This is the system default output
device in "normal" (=reliable but high latency) mode. In low-latency mode its the
device with the lowest inherent latency on your system (as determined by some internal
heuristic). If you are not satisfied with the results you may query the available devices
yourself via a call to devs = PsychPortAudio('GetDevices'); and provide the device index
of a suitable device

No "latbias" provided. Assuming zero bias. You'll need to determine this via measurement for best results...
PTB-INFO: Trying to suspend potentially running PulseAudio server... ... status 0
PTB-INFO: Using modified PortAudio V19.7.0-devel, revision 147dd722548358763a8b649b3e4b41dfffbcfbb6
PTB-INFO: Choosing deviceIndex 0 [HDA Intel PCH: ALC3861 Analog (hw:0,0)] as default output audio device.
PTB-INFO: New audio device -1 with handle 0 opened as PortAudio stream:
PTB-INFO: For 2 channels Playback: Audio subsystem is ALSA, Audio device name is HDA Intel PCH: ALC3861 Analog (hw:0,0)
PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000 msecs, Output latency 9.977324 msecs.

prelat =

     0


postlat =

     0



PTB-INFO: This is Psychtoolbox-3 for GNU/Linux X11, under Matlab 64-Bit (Version 3.0.18 - Build date: Jun 27 2022).
PTB-INFO: OS support status: Linux 5.19.0-35-generic Supported.
PTB-INFO: Type 'PsychtoolboxVersion' for more detailed version information.
PTB-INFO: Most parts of the Psychtoolbox distribution are licensed to you under terms of the MIT License, with
PTB-INFO: some restrictions. See file 'License.txt' in the Psychtoolbox root folder for the exact licensing conditions.

PTB-INFO: For information about paid support, support memberships and other commercial services, please type
PTB-INFO: 'PsychPaidSupportAndServices'.



PTB-INFO: OpenGL-Renderer is AMD :: AMD Radeon RX 6600 XT (navi23, LLVM 15.0.6, DRM 3.47, 5.19.0-35-generic) :: 4.6 (Compatibility Profile) Mesa 22.2.5
PTB-INFO: VBL startline = 1080 , VBL Endline = -1
PTB-INFO: Measured monitor refresh interval from VBLsync = 8.336120 ms [119.959890 Hz]. (50 valid samples taken, stddev=0.000463 ms.)
PTB-INFO: Reported monitor refresh interval from operating system = 8.336251 ms [119.958000 Hz].
PTB-INFO: Small deviations between reported values are normal and no reason to worry.


Waiting 4 video refresh cycles before white-flash.
Predicted Latency: 9.283781 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000346
Delay start vs. played: 0.000512 secs, offset 0.012880
Buffersize 110, xruns = 0, playpos = 0.012880 secs.
Screen    expects visual onset at 1678698035.404530 secs.
PortAudio expects audio onset  at 1678698035.404529 secs.
Expected audio-visual delay is therefore -0.000477 msecs.
Predicted Latency: 9.901047 msecs.
Flip delay = 0.033344 secs.  Flipend vs. VBL 0.000379
Delay start vs. played: 0.000315 secs, offset 0.012630
Buffersize 110, xruns = 0, playpos = 0.012630 secs.
Screen    expects visual onset at 1678698036.454889 secs.
PortAudio expects audio onset  at 1678698036.454889 secs.
Expected audio-visual delay is therefore 0.000715 msecs.
Predicted Latency: 9.692907 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000309
Delay start vs. played: 0.000238 secs, offset 0.012358
Buffersize 110, xruns = 0, playpos = 0.012358 secs.
Screen    expects visual onset at 1678698037.505250 secs.
PortAudio expects audio onset  at 1678698037.505249 secs.
Expected audio-visual delay is therefore -0.000954 msecs.
Predicted Latency: 9.485722 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000271
Delay start vs. played: 0.000231 secs, offset 0.009615
Buffersize 110, xruns = 0, playpos = 0.009615 secs.
Screen    expects visual onset at 1678698038.555610 secs.
PortAudio expects audio onset  at 1678698038.555609 secs.
Expected audio-visual delay is therefore -0.000715 msecs.
Predicted Latency: 9.802341 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000323
Delay start vs. played: 0.001338 secs, offset 0.014308
Buffersize 110, xruns = 0, playpos = 0.014308 secs.
Screen    expects visual onset at 1678698039.605971 secs.
PortAudio expects audio onset  at 1678698039.605970 secs.
Expected audio-visual delay is therefore -0.000238 msecs.
Predicted Latency: 7.353783 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000236
Delay start vs. played: 0.000307 secs, offset 0.011587
Buffersize 110, xruns = 0, playpos = 0.011587 secs.
Screen    expects visual onset at 1678698040.656332 secs.
PortAudio expects audio onset  at 1678698040.656332 secs.
Expected audio-visual delay is therefore 0.000000 msecs.
Predicted Latency: 7.398844 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000370
Delay start vs. played: 0.000140 secs, offset 0.011315
Buffersize 110, xruns = 0, playpos = 0.011315 secs.
Screen    expects visual onset at 1678698041.706694 secs.
PortAudio expects audio onset  at 1678698041.706693 secs.
Expected audio-visual delay is therefore -0.000477 msecs.
Predicted Latency: 7.287264 msecs.
Flip delay = 0.033344 secs.  Flipend vs. VBL 0.000288
Delay start vs. played: 0.000142 secs, offset 0.008571
Buffersize 110, xruns = 0, playpos = 0.008571 secs.
Screen    expects visual onset at 1678698042.757055 secs.
PortAudio expects audio onset  at 1678698042.757055 secs.
Expected audio-visual delay is therefore 0.000238 msecs.
Predicted Latency: 9.284258 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000405
Delay start vs. played: 0.000140 secs, offset 0.010794
Buffersize 110, xruns = 0, playpos = 0.010794 secs.
Screen    expects visual onset at 1678698043.807418 secs.
PortAudio expects audio onset  at 1678698043.807417 secs.
Expected audio-visual delay is therefore -0.000238 msecs.
Predicted Latency: 9.987593 msecs.
Flip delay = 0.033345 secs.  Flipend vs. VBL 0.000200
Delay start vs. played: 0.000140 secs, offset 0.010544
Buffersize 110, xruns = 0, playpos = 0.010544 secs.
Screen    expects visual onset at 1678698044.857780 secs.
PortAudio expects audio onset  at 1678698044.857780 secs.
Expected audio-visual delay is therefore 0.000000 msecs.
PTB-INFO: Closing handle 0.
PTB-INFO: Trying to resume potentially suspended PulseAudio server... ... status 0


Summary:
AV Error: -0.000477 msecs.
AV Error: 0.000715 msecs.
AV Error: -0.000954 msecs.
AV Error: -0.000715 msecs.
AV Error: -0.000238 msecs.
AV Error: 0.000000 msecs.
AV Error: -0.000477 msecs.
AV Error: 0.000238 msecs.
AV Error: -0.000238 msecs.
AV Error: 0.000000 msecs.
TS Error:  msecs.



#################### ATTACHED HEADPHONES, RUN 2 #############################

>> PsychPortAudio('Verbosity', 10); PsychPortAudioTimingTest
Will test accuracy of scheduled sound onset, i.e. how well the driver manages to
emit sound at exactly the specified "when" deadline. Sound should start in exact
sync with display black-white transition (or at least very close - < 1 msec off).
The remaining bias can be corrected by providing the bias as "latbias" parameter
to this script. Variance of sound onset between trials should be very low, much
smaller than 1 millisecond on a well working system.

Will use auto-selected default output device. This is the system default output
device in "normal" (=reliable but high latency) mode. In low-latency mode its the
device with the lowest inherent latency on your system (as determined by some internal
heuristic). If you are not satisfied with the results you may query the available devices
yourself via a call to devs = PsychPortAudio('GetDevices'); and provide the device index
of a suitable device

No "latbias" provided. Assuming zero bias. You'll need to determine this via measurement for best results...
PTB-INFO: Trying to suspend potentially running PulseAudio server... ... status 0
PTB-INFO: Using modified PortAudio V19.7.0-devel, revision 147dd722548358763a8b649b3e4b41dfffbcfbb6
PTB-INFO: Choosing deviceIndex 0 [HDA Intel PCH: ALC3861 Analog (hw:0,0)] as default output audio device.
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Illegal combination of I/O devices 
PTB-ERROR: This could be, e.g., due to an unsupported combination of audio sample rate, audio channel count/allocation, or audio sample format.
PTB-ERROR: On Linux you may be able to use ALSA audio converter plugins to make this work.
Error in function Open: 	Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Error using PsychPortAudio
Usage:

pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][,
selectchannels][, specialFlags=0]);

Error in PsychPortAudioTimingTest (line 161)
pahandle = PsychPortAudio('Open', deviceid, [], reqlatencyclass, freq, 2, buffersize, suggestedLatencySecs);


################################### Output from Terminal #############################

locallab@helmholtz:~$ ptb3-matlab 
Gtk-Message: 09:59:21.060: Failed to load module "canberra-gtk-module"
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
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
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
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
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
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
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
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
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
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'

You could send it via e-mail. Although i doubt it will be useful for diagnosing the problem, as none of this seems to be a kernel or audio driver bug, but something else.

I wonder if it is some race condition or peculiar interaction on your machine between forcing the pulseaudio sound server to suspend at each ‘Open’ and resuming again at each ‘Close’. The current method of handshaking between the pulseaudio sound server and our exclusive access to the soundcard is ad-hoc, more a hack than a clean solution, but it worked well enough throughout the last 14 years. Maybe it shows some cracks now… It could be improved with more effort, but again → lack of funding → lack of priority for things that are not associated with / required by paying contract work, as long as the old stuff sort of holds up.

Maybe one thing one could try is launching Matlab via
LIBASOUND_DEBUG=1 matlab from a terminal and see if one gets to see some additional error messages when the failure happens.

If you followed that advice, then PsychPortAudio will keep the device open throughout the session, but also the pahandle you got can be used inside your script to use PsychPortAudio to output sound. The suggested use of slave devices even allows complete independence between what Beeper/Snd does and what your own script does. Iow. its a solvable problem for any given script.

Wrt. Datapixx built in sound, it has its uses but is not always the better solution. PsychPortAudio is way more flexible, capable, feature-rich and easy to use than the Datapixx sound, also portable to non-Vpixx setups. The timing for scheduled sounds, ie. if one knows a few milliseconds ahead if and when one wants to play a sound, should be generally almost as good (an error in the few dozen or few hundreds microsecond range on Linux vs. maybe a few microseconds with Datapixx sound - whatever their inherent delay is – probably a few sample durations). Latency can be also in the low single-digit msecs range for starting sound “without warning”, e.g., in response to some trigger signal, subject response etc., with suitable sound cards. I think the only real slight advantage of the VPixx builtin sound is only if you need guaranteed perfect sync to visual stimulus onset, ie. by using the builtin hardware Psync mechanism for that. The PsychDatapixx driver has helper functions to optimally marry such commands to PTB’s visual presentation timing, although I don’t think we have demos for video-synced audio playback, only for video-synced audio capture (cfe. DatapixxAudioKey.m and PsychPortAudioDataPixxTimingTest.m for understanding to concepts for optimal interop and audio-video sync with PTB, the principle translates from audio capture to audio playback). Not sure if any of VPixx demos actually show optimal use with PTB when it comes to other modalities than the visual stuff.

For any timed audio playback other than triggered by visual stimulus onset, I’d expect timing to be not better than with PsychPortAudio, as start of playback would need to be triggered via a USB data transfer from the host, which would be more noisy than what PsychPortAudio’s scheduling can do. Unless ofc. I’m missing some new functionality added recently by VPixx that I’m not aware of - I’m not following new developments closely.

Just saying, which is the better solution to sound is highly dependent on task and circumstances.

Out of interest, why do you need VideoReader? PTB does have its own builtin GStreamer video playback engine which I’d assume to be superior for many/most use cases, and I don’t remember any GStreamer related problems with that on Ubuntu 22.04? One could use that engine also for just reading video frames into Matlab image matrices and writing new movies.

My bet in general, and I could be wrong of course, would be that those bugs might not have anything to do with Ubuntu 22 but more with whatever are the latest Matlab compatibility bugs in some recent Matlab release. Some teams at Mathworks are exceptionally incompetent, especially the ones related to plotting, graphics and multi-media related stuff. Often it is worth trying how PTB behaves under Octave, to see if one is dealing with a Matlab bug instead.

The jack messages are meaningless. They always happen if no Jack audio server is running, but as long as one doesn’t want to use Jack for audio output they are of no consequence, just chatter…

Technically it is already not recommended for PTB 3.0.19 anymore, and I intend to upgrade my machines to Ubuntu 22.04.2-LTS very soon, as soon as the current project is finished and there is a good time to upgrade. It’s really on the way out. With the poor funding, I am no longer able to support two LTS versions in parallel. In the past I was striving to keep an LTS supported throughout its 5 years support lifespan, as that is also a quite common duration for scientific projects (grants, PhD projects, independent research groups), and continuity is nice. But if the majority of our users apparently doesn’t value the quality of our services, then I can’t value our users time anymore. Neither do I have the money for required hardware, nor for paying the work time for extra testing, support, compatibility efforts, even if i wanted to.

-mario