Open dezi opened 1 year ago
I have the same problem, and I can confirm that this does partially fix the microphone driver. Where there was once a lot of distortion, there is now none! But unfortunately, the audio completely stops after a few seconds.
The audiotest
driver works great.
EDIT: I have tracked down the issue with audio stopping to something involving miniaudio or ALSA. I added a LogProc
to the device, and found that the Stop
callback was being called after the log statements:
[ALSA] poll() failed.
[ALSA] Dropping capture device...
[ALSA] Dropping capture device successful.
[ALSA] Preparing capture device...
[ALSA] Preparing capture device successful.
I could not get any more information on why poll() failed
, except that this error is being raised from miniaudio.
I installed PulseAudio and ran the pulseaudio
daemon so that miniaudio would pick that backend instead, and now it's working without any problems! (after the patch was applied above)
I faced the same problem of severely distorted audio, and this solution worked for me.
Initially, ALSA wasn't providing any audio output; although I could record audio using arecord
, it wasn't being sent to the other side. After installing PulseAudio, the audio started working, but the quality remained heavily distorted. This fix by @dezi effectively resolved the distortion issue.
My hardware was a Rpi 4 running raspian os bookworm and a USB audio card
I am also experiencing issues with distorted audio, this worked for me.
thx
I had the same problem when using my bluetooth earbud some months ago, copy the buffer worked at that time. (with a usb headphone it was working fine without any patch in the same pc).
But now it's working fine for me without any patch, I don't know if it was an update on my Fedora or on pion/mediadevices.
schrockwell: I have also experienced the
[ALSA] poll() failed.
Bug.
You will find my solution here:
https://github.com/mackron/miniaudio/issues/836
Regards, dezi
The problem is in pkg/driver/microphone/microphone.go lines 133...
Callback function of malgo audio capture. The chunk buffer is send to channel. Malgo will reuse the buffer while it is beeing processed.
You have to make a copy of chunk before sending it to the channel.
Please fix. Regards, dezi