3

I'm running Debian 9.2.1 in VirtualBox 5.1.30 on a Windows 7 host. I'd like to use the PortAudio library in a project so it can be used on multiple platforms, but I can't get it to behave even with its own example programs.

After a fresh install and update of Debian, I installed the portaudio19-dev package and grabbed paex_sine.c from the current source distribution on PortAudio's site. It compiles fine (gcc paex_sine.c -lportaudio -lm), but when I run it I'm met with a slew of errors:

ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib setup.c:547:(add_elem) Cannot obtain info for CTL elem (MIXER,'IEC958 Playback Default',0,0,0): No such file or directory
ALSA lib setup.c:547:(add_elem) Cannot obtain info for CTL elem (MIXER,'IEC958 Playback Default',0,0,0): No such file or directory
ALSA lib setup.c:547:(add_elem) Cannot obtain info for CTL elem (MIXER,'IEC958 Playback Default',0,0,0): No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred
ALSA lib pcm.c:8306:(snd_pcm_recover) underrun occurred
...

The audio itself is very "choppy" and distorted, and I get similar results with a sample/test application I wrote myself. It seems like PortAudio's callback loop is running as fast as it possibly can, rather than waiting until the buffer is (nearly) empty to ask for more data. (Playing a WAV file with aplay works fine, so I'm reasonably sure the VM is configured correctly).

The PortAudio installation in my VM is self-reporting as version PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4, which appears to be the latest stable on their web site, but it's a year old. Is this a known issue with a fix? Some weird interaction with VirtualBox? Or should I be writing up a bug on the PortAudio issue tracker?

EDIT: I just tried on a physical machine using a Debian 9.2 Live CD. Both of my tests (the paex_sine sample and my WAV player) were able to complete playback successfully, though I did still get a few errors when initializing PortAudio:

ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave

This indicates to me that there's something about VirtualBox's audio "hardware" that's causing PortAudio to get totally screwed up, but I have a similar issue ("choppy," distorted playback) using the onboard audio on a Raspberry Pi 3. I'm not sure at this point whether to bring it up with the PortAudio team or the RPi folks, and I'd also like to know how to get rid of all those "Unknown PCM" errors.

migrated from stackoverflow.com Nov 5 '17 at 12:11

This question came from our site for professional and enthusiast programmers.

  • 2
    I have the same problem with a Ubuntu VirtualBox – rubystallion Dec 2 '17 at 4:23
  • Same on Ubuntu VMWare – Orionss Sep 20 '18 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy