[LAD] malloc in fftw

From: Maarten de Boer <mdb.list@email-addr-hidden>
Date: Wed Apr 07 2010 - 11:59:56 EEST

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

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Wed Apr 7 12:15:01 2010

This archive was generated by hypermail 2.1.8 : Wed Apr 07 2010 - 12:15:01 EEST