diff --git a/plugins/ladspa_effect/calf/src/utils.cpp b/plugins/ladspa_effect/calf/src/utils.cpp index d661c914f..c1c3eaff2 100644 --- a/plugins/ladspa_effect/calf/src/utils.cpp +++ b/plugins/ladspa_effect/calf/src/utils.cpp @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU Lesser General * Public License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #include @@ -85,13 +85,14 @@ std::string load_file(const std::string &src) while(!feof(f)) { char buffer[1024]; - int len = fread(buffer, 1, sizeof(buffer), f); + size_t len = fread(buffer, 1, sizeof(buffer), f); #if 0 if (len < 0) throw file_exception(src); #endif str += string(buffer, len); } + fclose(f); return str; } @@ -99,7 +100,7 @@ std::string i2s(int value) { char buf[32]; sprintf(buf, "%d", value); - + return std::string(buf); } @@ -140,7 +141,7 @@ file_exception::file_exception(const std::string &f) : message(strerror(errno)) , filename(f) , container(filename + ":" + message) -{ +{ text = container.c_str(); } diff --git a/plugins/ladspa_effect/swh/alias_1407.c b/plugins/ladspa_effect/swh/alias_1407.c index 03a05f7fd..cbc0fdd50 100644 --- a/plugins/ladspa_effect/swh/alias_1407.c +++ b/plugins/ladspa_effect/swh/alias_1407.c @@ -19,10 +19,10 @@ #ifdef WIN32 #define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) -int bIsFirstTime = 1; +int bIsFirstTime = 1; void _init(); // forward declaration #else -#define _WINDOWS_DLL_EXPORT_ +#define _WINDOWS_DLL_EXPORT_ #endif diff --git a/plugins/ladspa_effect/swh/allpass_1895.c b/plugins/ladspa_effect/swh/allpass_1895.c index 21b4a3fc0..192684794 100644 --- a/plugins/ladspa_effect/swh/allpass_1895.c +++ b/plugins/ladspa_effect/swh/allpass_1895.c @@ -19,10 +19,10 @@ #ifdef WIN32 #define _WINDOWS_DLL_EXPORT_ __declspec(dllexport) -int bIsFirstTime = 1; +int bIsFirstTime = 1; void _init(); // forward declaration #else -#define _WINDOWS_DLL_EXPORT_ +#define _WINDOWS_DLL_EXPORT_ #endif #include "ladspa-util.h" @@ -154,17 +154,17 @@ static void activateAllpass_n(LADSPA_Handle instance) { unsigned int sample_rate = plugin_data->sample_rate; long write_phase = plugin_data->write_phase; unsigned int minsize, size; - + if (plugin_data->max_delay && *plugin_data->max_delay > 0) minsize = sample_rate * *plugin_data->max_delay; else if (plugin_data->delay_time) minsize = sample_rate * *plugin_data->delay_time; else minsize = sample_rate; /* 1 second default */ - + size = 1; while (size < minsize) size <<= 1; - + /* calloc sets the buffer to zero. */ buffer = calloc(size, sizeof(LADSPA_Data)); if (buffer) @@ -286,7 +286,7 @@ static void runAllpass_n(LADSPA_Handle instance, unsigned long sample_count) { plugin_data->delay_samples = delay_samples = CALC_DELAY (delay_time); plugin_data->feedback = feedback = calc_feedback (delay_time, decay_time); } - + if (delay_time == last_delay_time) { long read_phase = write_phase - (long)delay_samples; LADSPA_Data *readptr = buffer + (read_phase & buffer_mask); diff --git a/plugins/ladspa_effect/tap/tap_rotspeak.c b/plugins/ladspa_effect/tap/tap_rotspeak.c index aa86f1ea9..5b60b1b42 100644 --- a/plugins/ladspa_effect/tap/tap_rotspeak.c +++ b/plugins/ladspa_effect/tap/tap_rotspeak.c @@ -118,55 +118,131 @@ typedef struct { /* Construct a new plugin instance. */ -LADSPA_Handle +LADSPA_Handle instantiate_RotSpkr(const LADSPA_Descriptor * Descriptor, unsigned long sample_rate) { - - LADSPA_Handle * ptr; - - if ((ptr = malloc(sizeof(RotSpkr))) != NULL) { - ((RotSpkr *)ptr)->sample_rate = sample_rate; - ((RotSpkr *)ptr)->run_adding_gain = 1.0; - if ((((RotSpkr *)ptr)->ringbuffer_h_L = + LADSPA_Handle * ptr; + + if ((ptr = malloc(sizeof(RotSpkr))) != NULL) { + RotSpkr* rotSpeak = (RotSpkr*)ptr; + rotSpeak->sample_rate = sample_rate; + rotSpeak->run_adding_gain = 1.0; + + if ((rotSpeak->ringbuffer_h_L = calloc(2 * PM_DEPTH, sizeof(LADSPA_Data))) == NULL) + { + free(ptr); return NULL; + } if ((((RotSpkr *)ptr)->ringbuffer_h_R = calloc(2 * PM_DEPTH, sizeof(LADSPA_Data))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(ptr); return NULL; - ((RotSpkr *)ptr)->buflen_h_L = ceil(0.3f * sample_rate / M_PI); - ((RotSpkr *)ptr)->buflen_h_R = ceil(0.3f * sample_rate / M_PI); - ((RotSpkr *)ptr)->pos_h_L = 0; - ((RotSpkr *)ptr)->pos_h_R = 0; + } + rotSpeak->buflen_h_L = ceil(0.3f * sample_rate / M_PI); + rotSpeak->buflen_h_R = ceil(0.3f * sample_rate / M_PI); + rotSpeak->pos_h_L = 0; + rotSpeak->pos_h_R = 0; - if ((((RotSpkr *)ptr)->ringbuffer_b_L = + if ((rotSpeak->ringbuffer_b_L = calloc(2 * PM_DEPTH, sizeof(LADSPA_Data))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(ptr); return NULL; - if ((((RotSpkr *)ptr)->ringbuffer_b_R = + } + if ((rotSpeak->ringbuffer_b_R = calloc(2 * PM_DEPTH, sizeof(LADSPA_Data))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(ptr); return NULL; - ((RotSpkr *)ptr)->buflen_b_L = ceil(0.3f * sample_rate / M_PI); - ((RotSpkr *)ptr)->buflen_b_R = ceil(0.3f * sample_rate / M_PI); - ((RotSpkr *)ptr)->pos_b_L = 0; - ((RotSpkr *)ptr)->pos_b_R = 0; + } + rotSpeak->buflen_b_L = ceil(0.3f * sample_rate / M_PI); + rotSpeak->buflen_b_R = ceil(0.3f * sample_rate / M_PI); + rotSpeak->pos_b_L = 0; + rotSpeak->pos_b_R = 0; + + if ((rotSpeak->eq_filter_L = calloc(1, sizeof(biquad))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(rotSpeak->ringbuffer_b_R); + free(ptr); + return NULL; + } + if ((rotSpeak->lp_filter_L = calloc(1, sizeof(biquad))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(rotSpeak->ringbuffer_b_R); + free(rotSpeak->eq_filter_L); + free(ptr); + return NULL; + } + if ((rotSpeak->hp_filter_L = calloc(1, sizeof(biquad))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(rotSpeak->ringbuffer_b_R); + free(rotSpeak->eq_filter_L); + free(rotSpeak->lp_filter_L); + free(ptr); + return NULL; + } + + if ((rotSpeak->eq_filter_R = calloc(1, sizeof(biquad))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(rotSpeak->ringbuffer_b_R); + free(rotSpeak->eq_filter_L); + free(rotSpeak->lp_filter_L); + free(rotSpeak->hp_filter_L); + free(ptr); + return NULL; + } + if ((rotSpeak->lp_filter_R = calloc(1, sizeof(biquad))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(rotSpeak->ringbuffer_b_R); + free(rotSpeak->eq_filter_L); + free(rotSpeak->lp_filter_L); + free(rotSpeak->hp_filter_L); + free(rotSpeak->eq_filter_R); + free(ptr); + return NULL; + } + if ((rotSpeak->hp_filter_R = calloc(1, sizeof(biquad))) == NULL) + { + free(rotSpeak->ringbuffer_h_L); + free(rotSpeak->ringbuffer_h_R); + free(rotSpeak->ringbuffer_b_L); + free(rotSpeak->ringbuffer_b_R); + free(rotSpeak->eq_filter_L); + free(rotSpeak->lp_filter_L); + free(rotSpeak->hp_filter_L); + free(rotSpeak->eq_filter_R); + free(rotSpeak->lp_filter_R); + free(ptr); + return NULL; + } - if ((((RotSpkr *)ptr)->eq_filter_L = calloc(1, sizeof(biquad))) == NULL) - return NULL; - if ((((RotSpkr *)ptr)->lp_filter_L = calloc(1, sizeof(biquad))) == NULL) - return NULL; - if ((((RotSpkr *)ptr)->hp_filter_L = calloc(1, sizeof(biquad))) == NULL) - return NULL; - - if ((((RotSpkr *)ptr)->eq_filter_R = calloc(1, sizeof(biquad))) == NULL) - return NULL; - if ((((RotSpkr *)ptr)->lp_filter_R = calloc(1, sizeof(biquad))) == NULL) - return NULL; - if ((((RotSpkr *)ptr)->hp_filter_R = calloc(1, sizeof(biquad))) == NULL) - return NULL; - return ptr; } - + return NULL; } @@ -206,13 +282,13 @@ activate_RotSpkr(LADSPA_Handle Instance) { /* Connect a port to a data location. */ -void +void connect_port_RotSpkr(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data * DataLocation) { - + RotSpkr * ptr; - + ptr = (RotSpkr *)Instance; switch (Port) { case HORNFREQ: @@ -229,7 +305,7 @@ connect_port_RotSpkr(LADSPA_Handle Instance, break; case LATENCY: ptr->latency = DataLocation; - *(ptr->latency) = ptr->buflen_h_L / 2; /* IS THIS LEGAL? */ + *(ptr->latency) = ptr->buflen_h_L / 2; /* IS THIS LEGAL? YES, ONLY IF DataLocation points to valid memory location on stack/heap*/ break; case INPUT_L: ptr->input_L = DataLocation; @@ -248,10 +324,10 @@ connect_port_RotSpkr(LADSPA_Handle Instance, -void +void run_RotSpkr(LADSPA_Handle Instance, unsigned long SampleCount) { - + RotSpkr * ptr = (RotSpkr *)Instance; LADSPA_Data * input_L = ptr->input_L; diff --git a/plugins/ladspa_effect/tap/tap_vibrato.c b/plugins/ladspa_effect/tap/tap_vibrato.c index c518116d2..6b9cc21ff 100644 --- a/plugins/ladspa_effect/tap/tap_vibrato.c +++ b/plugins/ladspa_effect/tap/tap_vibrato.c @@ -1,6 +1,6 @@ /* -*- linux-c -*- Copyright (C) 2004 Tom Szilagyi - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -85,19 +85,22 @@ typedef struct { /* Construct a new plugin instance. */ -LADSPA_Handle +LADSPA_Handle instantiate_Vibrato(const LADSPA_Descriptor * Descriptor, unsigned long sample_rate) { - + LADSPA_Handle * ptr; - + if ((ptr = malloc(sizeof(Vibrato))) != NULL) { ((Vibrato *)ptr)->sample_rate = sample_rate; ((Vibrato *)ptr)->run_adding_gain = 1.0f; - if ((((Vibrato *)ptr)->ringbuffer = + if ((((Vibrato *)ptr)->ringbuffer = calloc(2 * PM_DEPTH, sizeof(LADSPA_Data))) == NULL) + { + free(ptr); return NULL; + } ((Vibrato *)ptr)->buflen = ceil(0.2f * sample_rate / M_PI); ((Vibrato *)ptr)->pos = 0; diff --git a/src/core/audio/AudioFileOgg.cpp b/src/core/audio/AudioFileOgg.cpp index 24148bc26..8e09d0a9d 100644 --- a/src/core/audio/AudioFileOgg.cpp +++ b/src/core/audio/AudioFileOgg.cpp @@ -122,7 +122,7 @@ bool AudioFileOgg::startEncoding() vorbis_info_clear( &m_vi ); return false; } - + if( useVBR() == false ) { vorbis_encode_ctl( &m_vi, OV_ECTL_RATEMANAGE_AVG, NULL ); @@ -132,7 +132,7 @@ bool AudioFileOgg::startEncoding() // Turn off management entirely (if it was turned on). vorbis_encode_ctl( &m_vi, OV_ECTL_RATEMANAGE_SET, NULL ); } - + vorbis_encode_setup_init( &m_vi ); // Now, set up the analysis engine, stream encoder, and other @@ -171,10 +171,12 @@ bool AudioFileOgg::startEncoding() { // clean up finishEncoding(); + delete[] user_comments; return false; } } + delete[] user_comments; return true; }