how to install portaudio on pi properly
Asked Answered
S

1

7

I am working on a project that involves recording from a mic on a raspberry pi. for now i am getting this error while the program is running.

python3: src/hostapi/alsa/pa_linux_alsa.c:3641: PaAlsaStreamComponent_BeginPolling: Assertion `ret == self->nfds' failed. Aborted

while searching for ways to fix this, i figured out the file pa_linux_alsa.c belongs to port audio. please refer to the following links.

modified pa_linux_alsa.c i think

how to install port audio

download link

first link is about the error and a modified fix, still dont know where to copy and the last two are about installing portaudio. apparently there is no easier way to install this with a command.

i downloaded the pa_snapshot enhanced version of it. but i dont know where i am supposed to put these files to begin to configure and make as in the readme. I copied the portaudio directory in to home/pi (in the user i think. "cd" and copied it there) then did as in the readme and rebooted the system. i dont see any changes in the error in program. i tried using the command whereis with pa_linux_alsa.c. that command also doesn't show the file or anything related to portaudio.

Sideswipe answered 23/11, 2019 at 9:5 Comment(1)
To anyone coming here, this issue is not exclusive to Raspberri PiBurnejones
C
11

Your first link correctly identifies a bug in portaudio, but the fix is incomplete. I forked the portaudio library and created a patch to fix this. Here are the steps to remove the portaudio package and compile the patched version from source:

sudo apt-get remove libportaudio2
sudo apt-get install libasound2-dev
git clone -b alsapatch https://github.com/gglockner/portaudio
cd portaudio
./configure && make
sudo make install
sudo ldconfig
cd ..

At this point, you should have a patched portaudio library, based on the pa_stable_v190600_20161030 tag. Finally, if you need the PyAudio package for Python, then install it using pip: sudo pip3 install pyaudio.

Cuttle answered 24/3, 2020 at 4:18 Comment(6)
commit 80aafc6 (i.e. tip of your alsapatch branch) seems to unnecessarily remove a lot of error handling. I submitted a tidier version of the patch to the portaudio mailing list which might be preferableProvocative
Does anyone know if this has been fully addressed/solved upstream already?Burnejones
I've just noticed that Debian is pulling in my patch now. Hence using package version 19.6.0-1.1 (or later) would presumably fix it on Debian. Ubuntu doesn't seem to have picked it up yet, and I can't test because I'm using Arch these daysProvocative
Looks like it made it into the next Ubuntu release, if I'm looking properly.Burnejones
From what I can see a fix for this (switching the assertion to at least better error handling) was merged with this pull request github.com/PortAudio/portaudio/pull/344 on 18. December 2020Rosalindarosalinde
This post needs more up-votes. The first post I've seen for this specific issue that actually works.Ingaingaberg

© 2022 - 2024 — McMap. All rights reserved.