Audio Input Example Crashing

Hi, the Audio Input example is crashing and I get 2 errors:

1. RtAudio: no compiled support for specified API argument!
2. malloc(): unaligned tcache chunk detected

Here is the entire message:

15:25:42: Starting /home/openFrameworks/examples/sound/audioInputExample/bin/audioInputExample_debug...
[notice ] ofBaseSoundStream::printDeviceList: 

[notice ] ofBaseSoundStream::printDeviceList: Api: Alsa
[notice ] ofBaseSoundStream::printDeviceList: [Alsa: 0] default [in:32 out:32] (default in) (default out)
[Alsa: 1] hw:HDA Intel HDMI,3 [in:0 out:8]
[Alsa: 2] hw:HDA Intel HDMI,7 [in:0 out:8]
[Alsa: 3] hw:HDA Intel HDMI,8 [in:0 out:8]
[Alsa: 4] hw:HDA Intel HDMI,9 [in:0 out:8]
[Alsa: 5] hw:HDA Intel HDMI,10 [in:0 out:8]
[Alsa: 6]  [in:0 out:0]

[notice ] ofBaseSoundStream::printDeviceList: Api: Pulse
[notice ] ofBaseSoundStream::printDeviceList: [Pulse: 0] Built-in Audio Analog Stereo [in:2 out:2] (default in) (default out)


RtAudio: no compiled support for specified API argument!

[notice ] ofBaseSoundStream::printDeviceList: Api: Jack
[notice ] ofBaseSoundStream::printDeviceList: [Jack: 0] Built-in Audio Analog Stereo [in:4 out:2] (default in) (default out)
[Jack: 1] Built-in Audio Analog Stereo Monitor [in:2 out:0]
[Jack: 2] GNOME Settings [in:4 out:4]
[Jack: 3] GNOME Settings Monitor [in:4 out:0]
[Jack: 4] GNOME Settings [in:4 out:4]
[Jack: 5] GNOME Settings Monitor [in:4 out:0]

[notice ] ofBaseSoundStream::printDeviceList: Api: OSX Core Audio
[notice ] ofBaseSoundStream::printDeviceList: [OSX Core Audio: 0] Built-in Audio Analog Stereo [in:4 out:2] (default in) (default out)
[OSX Core Audio: 1] Built-in Audio Analog Stereo Monitor [in:2 out:0]
[OSX Core Audio: 2] GNOME Settings [in:4 out:4]
[OSX Core Audio: 3] GNOME Settings Monitor [in:4 out:0]
[OSX Core Audio: 4] GNOME Settings [in:4 out:4]
[OSX Core Audio: 5] GNOME Settings Monitor [in:4 out:0]

[notice ] ofBaseSoundStream::printDeviceList: Api: MS WASAPI
[notice ] ofBaseSoundStream::printDeviceList: [MS WASAPI: 0] Built-in Audio Analog Stereo [in:4 out:2] (default in) (default out)
[MS WASAPI: 1] Built-in Audio Analog Stereo Monitor [in:2 out:0]
[MS WASAPI: 2] GNOME Settings [in:4 out:4]
[MS WASAPI: 3] GNOME Settings Monitor [in:4 out:0]
[MS WASAPI: 4] GNOME Settings [in:4 out:4]
[MS WASAPI: 5] GNOME Settings Monitor [in:4 out:0]

[notice ] ofBaseSoundStream::printDeviceList: Api: MS ASIO
[notice ] ofBaseSoundStream::printDeviceList: [MS ASIO: 0] Built-in Audio Analog Stereo [in:4 out:2] (default in) (default out)
[MS ASIO: 1] Built-in Audio Analog Stereo Monitor [in:2 out:0]
[MS ASIO: 2] GNOME Settings [in:4 out:4]
[MS ASIO: 3] GNOME Settings Monitor [in:4 out:0]
[MS ASIO: 4] GNOME Settings [in:4 out:4]
[MS ASIO: 5] GNOME Settings Monitor [in:4 out:0]

[notice ] ofBaseSoundStream::printDeviceList: Api: MS DirectShow
[notice ] ofBaseSoundStream::printDeviceList: [MS DirectShow: 0] Built-in Audio Analog Stereo [in:4 out:2] (default in) (default out)
[MS DirectShow: 1] Built-in Audio Analog Stereo Monitor [in:2 out:0]
[MS DirectShow: 2] GNOME Settings [in:4 out:4]
[MS DirectShow: 3] GNOME Settings Monitor [in:4 out:0]
[MS DirectShow: 4] GNOME Settings [in:4 out:4]
[MS DirectShow: 5] GNOME Settings Monitor [in:4 out:0]

malloc(): unaligned tcache chunk detected
15:25:44: /home/openFrameworks/examples/sound/audioInputExample/bin/audioInputExample_debug crashed.

 
RtAudio: no compiled support for specified API argument!

//

Does anyone know what the issue is ?

Thank you !!!
W

the Audio Output example is also not running, so it’s an audio issue all around…

it also give the rtAudio error:
RtAudio: no compiled support for specified API argument!

and this one:
[ error ] RtApiJack::probeDeviceOpen: the requested sample rate (44100) is different than the JACK server rate (48000).

when I change the sample rate to 48000, it crashes and gives me this error:
corrupted size vs. prev_size

Hi :slight_smile: What’s the smallest program showing this error? Does changing the sample rate in qjackctl make any difference?

Hi :slight_smile: In settings, I tried both 44100 and 48000 as default sample rates but no changes. the build crashes as soon as it starts to run.

Hey @WillpowerStudios , you are running ubuntu 22.04, right? I’ve been following some of the previous threads in the forum. Could this be arising from another missing package? Maybe make sure that the RtAudio package has been installed. I’m not certain about the specifics, but maybe something related to librtaudio, or librtaudio-dev, etc.

Because of the previous threads, I put ubuntu 22.04 on a (very) old laptop and had a horrendous time with packages as they relate to both oF and Qt. I eventually gave up. When I’ve installed Mint in the past, everything has worked just fine. So I feel like this 22.04 release of ubuntu is particularly problematic and seems to be missing some of the typical linux packages for some reason.

Hi TimChi, thank you so much for your input ! Yes indeed, I have been having issues with QT and oF I never experienced prior to 22.04. I’m glad QT is now working ! I just installed librtaudio and although it says that it is already the newest version, the Audio Output example is now working ! The Audio Input on the other hand crashes immediately, so there is still something potentially missing…
I am getting this error for Audio Input projects:

munmap_chunk(): invalid pointer
09:13:40: /home/openFrameworks/examples/sound/audioOutputExample/bin/audioOutputExample_debug crashed.

also:
‘o != NULL’ failed at …/pipewire-jack/src/pipewire-jack.c:4491 jack_port_get_buffer()

I sat with a friend who helped me figure things out, it’s running and I can use Audio Input :smiley: :partying_face:

These are the changes:

// or by name
//	auto devices = soundStream.getMatchingDevices("default");
//	if(!devices.empty()){
//		settings.setInDevice(devices[0]);
//    }

	settings.setInListener(this);
//    settings.sampleRate = 48000;
    settings.numOutputChannels = 0;
    settings.numInputChannels = 2;
//    settings.bufferSize = bufferSize;
    settings.setApi(ofSoundDevice::ALSA);
    soundStream.setup(settings);

As you can see, we specified ALSA for the sound device.
maybe its unclear for oF which api to use if not specified ?
unfortunately, it gives a weird error that I will share below.
I will mark this post as resolved but if anyone who is advanced knows how to fix it, please share if you can :slightly_smiling_face: :point_down:

[warning] ofSoundStreamSettings: Setting IN device with api: Unkown API will override the previously set: Alsa
RtAudio alsa: _NOT_ running realtime scheduling
1 Like

These are two separate warnings/errors/messages.

Instead of using setApi(), you should set the device:

    std::vector<ofSoundDevice> devices = soundStream.getDeviceList();
    settings.setOutDevice(devices[1]);

i know that on my machine I have two audio devices, ALSA (0) and Pulseaudio (1), hence the 1 in the second line (I want to use PulseAudio). You can use the debugger to see what is in the vector, use soundStream.printDeviceList() or code some user input.

oF tries to set the soundstream to REALTIME. This didn’t work in your case. Is your user in the audio group?

I had a similar problem with PulseAudio that I fixed by editing the /etc/security/limits.conf file.

Thanks for your reply !

Yes, I tried setting the device but it does not work… I wonder why…

What is the audio group ?

Hi! Can you show me your code and the error output? Or try this:

In ofApp.h I have a ofSoundStream object:

ofSoundStream soundStream;

in ofApp.cpp you can:

soundStream.printDeviceList();

to get a list of available devices. Use the order number to set the device:

ofSoundStreamSettings settings;
// soundStream.printDeviceList();
std::vector devices = soundStream.getDeviceList();
settings.setOutDevice(devices[1]);

where the devices[1] corresponds to the 2nd device (starting from 0).

On GNU/Linux every user belongs to different groups.

In a terminal, type

groups

to see which. You should be logged in as the same user that runs your code (the one you logged in as) when you do this. What groups do you belong to? audio?

Hi, thanks again.

So I gave it another shot and it worked 3 times. Then it keeps crashing. Then it works again… then crashes… etc… When it crashes, I get this error:

malloc(): unaligned tcache chunk detected

Do you know what it means and why it sometimes runs and sometimes crashes ?

this is the code I’m using, from your initial suggestion:

std::vector<ofSoundDevice> devices = soundStream.getDeviceList();
settings.setOutDevice(devices[1]);
soundStream.setup(settings);

//

When entering ‘groups’ in the terminal, I get this:

willpowerstudios adm dialout sudo lpadmin

What does it say about audio ?

1 Like

It is impossible for me to say where this error comes from, unfortunetaly. malloc() allocates memory. It might have to do with something else in your code?

It is a good idea to clean up the soundstream when exiting. I have this:

void ofApp::exit() {
    ofSoundStreamClose();
}

And you have init’ed the settings? This is how it looks at my end:

    ofSoundStreamSettings settings;
//    soundStream.printDeviceList();
    std::vector<ofSoundDevice> devices = soundStream.getDeviceList();
    settings.setOutDevice(devices[1]);
    settings.numOutputChannels = 2;
    settings.sampleRate = DSTUDIO_SAMPLE_RATE; // 44100
    settings.bufferSize = DSTUDIO_BUFFER_SIZE; // 512
    settings.numBuffers = DSTUDIO_NUM_BUFFERS; // 4

// here have code that inits objects that creates the sound in the audiocallback

    settings.setOutListener(this);
    soundStream.setup(settings);

For ALSA to run realtime I think you need to be also in the audio group, which you don’t seem to be:

sudo usermod –a –G audio willpowerstudios

should do it.

We are getting closer! :slight_smile:

Hi,

Yes, I have the settings initiated.
my code is in a different order. when I put it in the same order as you, it crashes on each attempt, whereas the way I had it before was running about half the time…

//

when entering

sudo usermod –a –G audio willpowerstudios

I get:



Usage: usermod [options] LOGIN

Options:
  -b, --badnames                allow bad names
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                the user from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -v, --add-subuids FIRST-LAST  add range of subordinate uids
  -V, --del-subuids FIRST-LAST  remove range of subordinate uids
  -w, --add-subgids FIRST-LAST  add range of subordinate gids
  -W, --del-subgids FIRST-LAST  remove range of subordinate gids
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account

Hi @WillpowerStudios!

The usermod should work if that is your username (willpowerstudios). Make sure you type the command, not copy and paste from the webpage as that might introduce some strange characters in the commandline. The dash before the characters might have been converted for example.

As for the other errors I think I need to see the whole of your code, if possible! One problem could be that the processing in the callback is not init’ed before it is started (which is done by the soundStream.setup(settings) call).