Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libprojectM/MilkdropPresetFactory/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ class MultAndAddExpr : public Expr
a(_a), b(_b), c(_c)
{
}
~MultAndAddExpr() {
delete a;
delete b;
delete c;
}
float eval(int mesh_i, int mesh_j)
{
float a_value = a->eval(mesh_i,mesh_j);
Expand Down
6 changes: 1 addition & 5 deletions src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ MilkdropPreset::~MilkdropPreset()
delete(*pos);
}
customWaves.clear();
customShapes.clear();
presetOutputs().customWaves.clear();
presetOutputs().customShapes.clear();
presetOutputs().drawables.clear();

customShapes.clear();
}

/* Adds a per pixel equation according to its string name. This
Expand Down
6 changes: 6 additions & 0 deletions src/libprojectM/MilkdropPresetFactory/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,10 @@ Expr * Parser::parse_gen_expr ( std::istream & fs, TreeExpr * tree_expr, Milkdr
return NULL;
//std::cout << gen_expr << std::endl;
Expr *opt = gen_expr->optimize();

if (opt != gen_expr) {
delete gen_expr;
}
//std::cout << opt << std::endl << std::endl;
return opt;
}
Expand Down Expand Up @@ -2460,6 +2464,8 @@ int Parser::parse_shape_per_frame_init_eqn(std::istream & fs, CustomShape * cus

line_mode = CUSTOM_SHAPE_PER_FRAME_INIT_LINE_MODE;
init_cond->evaluate(true);

delete init_cond;
return PROJECTM_SUCCESS;
}

Expand Down
5 changes: 4 additions & 1 deletion src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ PresetOutputs::~PresetOutputs()
this->rot_mesh = free_mesh(this->rot_mesh);
this->orig_x = free_mesh(this->orig_x);
this->orig_y = free_mesh(this->orig_y);

customWaves.clear();
customShapes.clear();
drawables.clear();
}


Expand Down Expand Up @@ -457,7 +461,6 @@ void PresetOutputs::Initialize ( int gx, int gy )
this->gy = gy;

staticPerPixel = true;
setStaticPerPixel(gx,gy);

assert(this->gx > 0);
int x;
Expand Down
4 changes: 2 additions & 2 deletions src/libprojectM/PCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ int PCM::maxsamples = 2048;
// number of samples specified.
#include <iostream>
PCM::PCM() {
initPCM( 2048 );
_initPCM( 2048 );

#ifdef DEBUG
std::cerr << "[PCM] MAX SAMPLES:" << maxsamples << std::endl;
#endif
}

void PCM::initPCM(int samples) {
void PCM::_initPCM(int samples) {
int i;

waveSmoothing = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/libprojectM/PCM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ PCM {
static int maxsamples;
PCM();
~PCM();
void initPCM(int maxsamples);
void addPCMfloat(const float *PCMdata, int samples);
void addPCM16(short [2][512]);
void addPCM16Data(const short* pcm_data, short samples);
Expand All @@ -68,6 +67,8 @@ PCM {
void freePCM();
int getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive,int reset);

private:
void _initPCM(int maxsamples);

};

Expand Down
7 changes: 6 additions & 1 deletion src/libprojectM/Renderer/RenderItemDistanceMetric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/// when they are dissimilar. If two render items cannot be compared, NOT_COMPARABLE_VALUE is returned.
class RenderItemDistanceMetric : public std::binary_function<const RenderItem*, const RenderItem*, double> {
public:
virtual ~RenderItemDistanceMetric() { }
const static double NOT_COMPARABLE_VALUE;
virtual double operator()(const RenderItem * r1, const RenderItem * r2) const = 0;
virtual TypeIdPair typeIdPair() const = 0;
Expand Down Expand Up @@ -103,7 +104,11 @@ typedef std::map<TypeIdPair, RenderItemDistanceMetric*> DistanceMetricMap;
public:

MasterRenderItemDistance() {}
virtual ~MasterRenderItemDistance() {}
virtual ~MasterRenderItemDistance() {
for (DistanceMetricMap::iterator it = _distanceMetricMap.begin(); it != _distanceMetricMap.end(); ++it)
delete (it->second);
_distanceMetricMap.clear();
}

inline void addMetric(RenderItemDistanceMetric * fun) {
_distanceMetricMap[fun->typeIdPair()] = fun;
Expand Down
7 changes: 6 additions & 1 deletion src/libprojectM/Renderer/RenderItemMergeFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ inline bool interpolate(bool a, bool b, float ratio)
/// when they are dissimilar. If two render items cannot be compared, NOT_COMPARABLE_VALUE is returned.
class RenderItemMergeFunction {
public:
virtual ~RenderItemMergeFunction() {}
virtual RenderItem * operator()(const RenderItem * r1, const RenderItem * r2, double ratio) const = 0;
virtual TypeIdPair typeIdPair() const = 0;
};
Expand Down Expand Up @@ -201,7 +202,11 @@ typedef std::map<TypeIdPair, RenderItemMergeFunction*> MergeFunctionMap;
public:

MasterRenderItemMerge() {}
virtual ~MasterRenderItemMerge() {}
virtual ~MasterRenderItemMerge() {
for (MergeFunctionMap::iterator it = _mergeFunctionMap.begin(); it != _mergeFunctionMap.end(); ++it)
delete (it->second);
_mergeFunctionMap.clear();
}

inline void add(RenderItemMergeFunction * fun) {
_mergeFunctionMap[fun->typeIdPair()] = fun;
Expand Down
20 changes: 18 additions & 2 deletions src/libprojectM/projectM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ projectM::~projectM()
_pcm = 0;
}

if(timeKeeper) {
delete timeKeeper;
timeKeeper = NULL;
}

delete(_pipelineContext);
delete(_pipelineContext2);
}
Expand All @@ -117,7 +122,8 @@ void projectM::projectM_resetTextures()


projectM::projectM ( std::string config_file, int flags) :
beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext())
beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()),
timeKeeper(NULL), _matcher(NULL), _merger(NULL)
{
readConfig(config_file);
projectM_reset();
Expand All @@ -126,7 +132,8 @@ beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pip
}

projectM::projectM(Settings settings, int flags):
beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext())
beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()),
timeKeeper(NULL), _matcher(NULL), _merger(NULL)
{
readSettings(settings);
projectM_reset();
Expand Down Expand Up @@ -652,6 +659,15 @@ static void *thread_callback(void *prjm) {

m_presetLoader = 0;

if (_matcher) {
delete _matcher;
_matcher = NULL;
}

if (_merger) {
delete _merger;
_merger = NULL;
}
}

/// @bug queuePreset case isn't handled
Expand Down
1 change: 0 additions & 1 deletion src/projectM-sdl/pmSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void projectMSDL::beginAudioCapture() {
// allocate a buffer to store PCM data for feeding in
unsigned int maxSamples = audioChannelsCount * audioSampleCount;
SDL_PauseAudioDevice(audioDeviceID, false);
pcm()->initPCM(2048);
}

void projectMSDL::endAudioCapture() {
Expand Down