From d1353247d91f7e7da469e6c29f92f8c1b8c7b9b1 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 --- 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 3f1e5458e..eee6837dc 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -657,7 +657,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; @@ -668,7 +672,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",