From cfe9c35f41501cf8a982f0b83a1ea8afa4d88fc2 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 5 Jul 2009 16:33:49 +0200 Subject: [PATCH] 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 (cherry picked from commit d1353247d91f7e7da469e6c29f92f8c1b8c7b9b1) --- plugins/sf2_player/sf2_player.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 50d5b0fa6..75d54ab65 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -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",