RpiANC
RpiANC copied to clipboard
performance issue on Raspberry 3A+ or 4B, "capture overrun occurred" and "playback underrun occurred" printed
As a newcomer to noise cancellation, I've encountered some issues while using your impressive project. Specifically, I've noticed frequent occurrences of "capture overrun" and "playback underrun" messages during processing.
I understand that it has been some time since you completed this project, but I am still hopeful for your kindly help.
Following is my environment setup:
- Raspberry Pi 3A+ (and also Raspberry Pi 4B 2GB)
- OS: raspbian-2020-02-14, latest distribution since the old distributions were out of maintenace
- 2 * I2S micrphones, same model and wire connected, installed driver version: 1:2.20.1
- CMake: 3.16.3
- libasound2 and libasound2-dev are installed, version: 1.1.8-1+rpt2
- test app: ffANC
The first issue I met is the minimum period size of device is much larger than the value in constants.h, the log shows:
pi@raspberrypi:~/works/RpiANC/build $ ./ffANC
Capture params: Capture rate: 44100 Period size: 32 Min period size: 32
Playback params: Playback rate: 44100 Period size: 444 Play min period size: 443 Buffer size: 4096
access type = RW_INTERLEAVED
subformat = 'STD' (Standard)
channels = 2
rate = 44100 bps
period time = 10068 us
period size = 444 frames
period size = 3552 bytes
buffer time = 10068 us
buffer size = 4096 frames
periods per buffer = 9 frames
min period size = 444 frames
min buffer size = 4096 frames
exact rate = 44101/1 bps
significant bits = 32
is batch = 0
is block transfer = 1
is double = 0
is half duplex = 0
is joint duplex = 0
can overrange = 0
can mmap = 0
can pause = 0
can resume = 0
can sync start = 0
Number of play frames per period ( 444 ) then configuration ( 32 )
It passes after I modified the value to 444 on both capture and playback, but I don't know if this modification is correct.
The second issue is the debug message prints frequently, it seems reporting the performance down:
pi@raspberrypi:~/works/RpiANC/build $ ./ffANC
Capture params: Capture rate: 44100 Period size: 444 Min period size: 32
Playback params: Playback rate: 44101 Period size: 444 Play min period size: 443 Buffer size: 31080
access type = RW_INTERLEAVED
subformat = 'STD' (Standard)
channels = 2
rate = 44101 bps
period time = 10068 us
period size = 444 frames
period size = 3552 bytes
buffer time = 10068 us
buffer size = 31080 frames
periods per buffer = 69 frames
min period size = 444 frames
min buffer size = 31080 frames
exact rate = 44101/1 bps
significant bits = 32
is batch = 0
is block transfer = 1
is double = 0
is half duplex = 0
is joint duplex = 0
can overrange = 0
can mmap = 0
can pause = 0
can resume = 0
can sync start = 0
playback underrun occurred
playback underrun occurred
playback underrun occurred
playback underrun occurred
capture overrun occurred
playback underrun occurred
playback underrun occurred
playback underrun occurred
playback underrun occurred
capture overrun occurred
playback underrun occurred
playback underrun occurred
playback underrun occurred
playback underrun occurred
playback underrun occurred
capture overrun occurred
playback underrun occurred
repeating...
playback underrun occurred
Cap time
Average: 8650.68
proc time
Average: 58917.6
play time
Average: 390.66
total time
Average: 63423.4
ffANC: /home/pi/works/RpiANC/Sources/common.cpp:22: void save_vector_to_file(const string&, const std::vector<long int>&): Assertion `file.is_open()' failed.
Aborted
During processing, htop shows two cores are about 60% to 80% usage, another two are in low usage. (seems OpenMP works fine).
And the log shows the processing time is much more than required: 58.9ms vs. 10ms(444 samples in 44.1Khz)
I would greatly appreciate your help in resolving these issues. Thank you!
Hello! Thanks for your interest in that project!
For the first problem, yes, the minimum period size is hardcoded in the driver for the audio devices. But it's possible to modify driver's source coude, lower the minimum value, recompile and use your version.
Could you also check the previous issues, maybe you would find useful information there? For example:
- https://github.com/psykulsk/RpiANC/issues/1
- https://github.com/psykulsk/RpiANC/issues/7
Hope that will help a little!