diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2007-10-16 09:37:06 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2007-10-16 09:37:06 +0000 |
commit | 9ca79a2cc14c18758baa1adfaead49e70d80003e (patch) | |
tree | b49f1ecfc58fee377d1fa223846862d9e98d89e8 /src/init.c | |
parent | 0fbfa15686542864a067b3b03b698a024772eae3 (diff) | |
download | LibXtract-9ca79a2cc14c18758baa1adfaead49e70d80003e.tar.gz LibXtract-9ca79a2cc14c18758baa1adfaead49e70d80003e.tar.bz2 LibXtract-9ca79a2cc14c18758baa1adfaead49e70d80003e.zip |
Fix for 'multiple symbol definitions' vs 'symbol not defined' dilemna. I think the solution is to wrap the globals in a struct, declare it in a header, and wrap with a definition guard, then define _once_ at library init time. (Sounds like a recipe for something...)
Diffstat (limited to 'src/init.c')
-rw-r--r-- | src/init.c | 42 |
1 files changed, 27 insertions, 15 deletions
@@ -28,6 +28,7 @@ #include <stdlib.h> #include "xtract/libxtract.h" +#define DEFINE_GLOBALS #include "xtract_globals_private.h" #ifdef XTRACT_FFT @@ -166,30 +167,30 @@ int xtract_init_fft(int N, int feature_name){ switch(feature_name){ case XTRACT_SPECTRUM: - if(spectrum_plan != NULL) - fftwf_destroy_plan(spectrum_plan); - spectrum_plan = + if(fft_plans.spectrum_plan != NULL) + fftwf_destroy_plan(fft_plans.spectrum_plan); + fft_plans.spectrum_plan = fftwf_plan_r2r_1d(N, input, output, FFTW_R2HC, optimisation); break; case XTRACT_AUTOCORRELATION_FFT: - if(autocorrelation_fft_plan_1 != NULL) - fftwf_destroy_plan(autocorrelation_fft_plan_1); - if(autocorrelation_fft_plan_2 != NULL) - fftwf_destroy_plan(autocorrelation_fft_plan_2); - autocorrelation_fft_plan_1 = + if(fft_plans.autocorrelation_fft_plan_1 != NULL) + fftwf_destroy_plan(fft_plans.autocorrelation_fft_plan_1); + if(fft_plans.autocorrelation_fft_plan_2 != NULL) + fftwf_destroy_plan(fft_plans.autocorrelation_fft_plan_2); + fft_plans.autocorrelation_fft_plan_1 = fftwf_plan_r2r_1d(N, input, output, FFTW_R2HC, optimisation); - autocorrelation_fft_plan_2 = + fft_plans.autocorrelation_fft_plan_2 = fftwf_plan_r2r_1d(N, input, output, FFTW_HC2R, optimisation); break; case XTRACT_DCT: - if(dct_plan != NULL) - fftwf_destroy_plan(dct_plan); - dct_plan = + if(fft_plans.dct_plan != NULL) + fftwf_destroy_plan(fft_plans.dct_plan); + fft_plans.dct_plan = fftwf_plan_r2r_1d(N, input, output, FFTW_REDFT00, optimisation); case XTRACT_MFCC: - if(dct_plan != NULL) - fftwf_destroy_plan(dct_plan); - dct_plan = + if(fft_plans.dct_plan != NULL) + fftwf_destroy_plan(fft_plans.dct_plan); + fft_plans.dct_plan = fftwf_plan_r2r_1d(N, output, output, FFTW_REDFT00, optimisation); break; } @@ -216,3 +217,14 @@ int xtract_init_bark(int N, float sr, int *band_limits){ return XTRACT_SUCCESS; } +#ifdef __GNUC__ +__attribute__((constructor)) void init() +#else + void _init()ยท +#endif +{ + fft_plans.spectrum_plan = NULL; + fft_plans.autocorrelation_fft_plan_1 = NULL; + fft_plans.autocorrelation_fft_plan_2 = NULL; + fft_plans.dct_plan = NULL; +} |