[LAD] malloc in fftw
Maarten de Boer
mdb.list at resorama.com
Wed Apr 7 08:59:56 UTC 2010
Hi,
I suppose that many of you are or might be using fftw for real-time audio processing, and I think the following information may be of your interest.
I just came to realize that fftw_execute calls malloc. This happens even though you create a 'plan' where you pass fftw_malloc preallocated input and output buffers.
It goes without saying that calling malloc is bad practice for audio callbacks, but as a reference I quote the jack_set_process_callback documentation:
The code in the supplied function must be suitable for real-time execution.
That means that it cannot call functions that might block for a long time.
This includes malloc, free, printf, pthread_mutex_lock, sleep, wait, poll,
select, pthread_join, pthread_cond_wait, etc, etc.
I wrote the fftw developers and they confirmed the memory allocation takes place. They suggested the following:
> Try planning with the undocumented flag FFTW_NO_BUFFERING, which will
> prevent the use of malloc() in common cases. This is not
> foolproof---some transforms are very hard to do without additional
> buffers, but if all you are trying to do is vanilla out-of-place 1D
> transforms without large prime factors it should work.
Maarten
More information about the Linux-audio-dev
mailing list