Sf2Player: allocate temporary buffer on stack if possible

When compiling with GCC always allocate a temporary buffer for
resampling on stack rather than doing an expensive heap allocation.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
(cherry picked from commit d1353247d9)
This commit is contained in:
Tobias Doerffel
2009-07-05 16:33:49 +02:00
parent fa21cf10a9
commit cfe9c35f41

View File

@@ -604,7 +604,11 @@ void sf2Instrument::play( sampleFrame * _working_buffer )
{
const fpp_t f = frames * m_internalSampleRate /
engine::getMixer()->processingSampleRate();
#ifdef __GNUC__
sampleFrame tmp[f];
#else
sampleFrame * tmp = new sampleFrame[f];
#endif
fluid_synth_write_float( m_synth, f, tmp, 0, 2, tmp, 1, 2 );
SRC_DATA src_data;
@@ -615,7 +619,9 @@ void sf2Instrument::play( sampleFrame * _working_buffer )
src_data.src_ratio = (double) frames / f;
src_data.end_of_input = 0;
int error = src_process( m_srcState, &src_data );
#ifndef __GNUC__
delete[] tmp;
#endif
if( error )
{
printf( "sf2Instrument: error while resampling: %s\n",