zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 2894ee1a11f01e586a6c6ac3b810a1579309058f
parent 2fc8221cf15f109abe2f88ae6972a0da196dddf3
Author: fundamental <[email protected]>
Date:   Thu, 13 May 2010 18:57:03 -0400

Memory Managment: Cleanup

Diffstat:
Msrc/DSP/FFTwrapper.cpp | 5+++++
Msrc/DSP/FFTwrapper.h | 1+
Msrc/Misc/Master.cpp | 4++--
Msrc/Nio/AudioOut.cpp | 29++++++++---------------------
Msrc/Nio/AudioOut.h | 5++---
Msrc/Nio/NulEngine.cpp | 2+-
Msrc/Nio/OutMgr.cpp | 3+++
Msrc/Nio/SafeQueue.cpp | 2+-
8 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/src/DSP/FFTwrapper.cpp b/src/DSP/FFTwrapper.cpp @@ -134,3 +134,8 @@ void deleteFFTFREQS(FFTFREQS *f) f->c = f->s = NULL; } +void FFT_cleanup() +{ + fftw_cleanup(); +} + diff --git a/src/DSP/FFTwrapper.h b/src/DSP/FFTwrapper.h @@ -66,5 +66,6 @@ class FFTwrapper void newFFTFREQS(FFTFREQS *f, int size); void deleteFFTFREQS(FFTFREQS *f); +void FFT_cleanup(); #endif diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -64,7 +64,6 @@ Master::Master() //System Effects init for(int nefx = 0; nefx < NUM_SYS_EFX; nefx++) sysefx[nefx] = new EffectMgr(0, &mutex); - ; defaults(); @@ -473,7 +472,8 @@ Master::~Master() delete [] tmpmixl; delete [] tmpmixr; - delete (fft); + delete fft; + FFT_cleanup(); pthread_mutex_destroy(&mutex); pthread_mutex_destroy(&vumutex); diff --git a/src/Nio/AudioOut.cpp b/src/Nio/AudioOut.cpp @@ -30,58 +30,45 @@ using namespace std; #include "../Misc/Master.h" #include "AudioOut.h" -struct AudioOut::Data -{ - Data(); - - int samplerate; - int bufferSize; -}; - -AudioOut::Data::Data() - :samplerate(SAMPLE_RATE),bufferSize(SOUND_BUFFER_SIZE) -{} - AudioOut::AudioOut() - :dat(new Data()) + :samplerate(SAMPLE_RATE),bufferSize(SOUND_BUFFER_SIZE) {} AudioOut::~AudioOut() { - delete dat; } void AudioOut::setSamplerate(int _samplerate) { - dat->samplerate = _samplerate; + samplerate = _samplerate; } int AudioOut::getSampleRate() { - return dat->samplerate; + return samplerate; } void AudioOut::setBufferSize(int _bufferSize) { - dat->bufferSize = _bufferSize; + bufferSize = _bufferSize; } //delete me void AudioOut::bufferingSize(int nBuffering) { - //dat->buffering = nBuffering; + //buffering = nBuffering; } //delete me int AudioOut::bufferingSize() { - //return dat->buffering; + //return buffering; } const Stereo<Sample> AudioOut::getNext(bool wait) { - Stereo<REALTYPE *> tmp = OutMgr::getInstance().tick(dat->bufferSize); + Stereo<REALTYPE *> tmp = OutMgr::getInstance().tick(bufferSize); //stop the samples - return Stereo<Sample>(Sample(dat->bufferSize, tmp.l()), Sample(dat->bufferSize, tmp.r())); + return Stereo<Sample>(Sample(bufferSize, tmp.l()), Sample(bufferSize, tmp.r())); } diff --git a/src/Nio/AudioOut.h b/src/Nio/AudioOut.h @@ -54,9 +54,8 @@ class AudioOut : public virtual Engine * (has nsamples sampled at a rate of samplerate)*/ const Stereo<Sample> getNext(bool wait = false); - //using opaque pointer to reduce compile times - struct Data; - Data *dat; + int samplerate; + int bufferSize; }; #endif diff --git a/src/Nio/NulEngine.cpp b/src/Nio/NulEngine.cpp @@ -68,7 +68,7 @@ void *NulEngine::AudioThread() playing_until.tv_sec += playing_until.tv_usec / 1000000; playing_until.tv_usec %= 1000000; } - pthread_exit(NULL); + return NULL; } NulEngine::~NulEngine() diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp @@ -32,6 +32,9 @@ OutMgr::OutMgr() OutMgr::~OutMgr() { + delete wave; + delete [] priBuf.l(); + delete [] priBuf.r(); delete [] outr; delete [] outl; } diff --git a/src/Nio/SafeQueue.cpp b/src/Nio/SafeQueue.cpp @@ -13,7 +13,7 @@ SafeQueue<T>::~SafeQueue() { sem_destroy(&w_space); sem_destroy(&r_space); - delete[] buffer; + delete [] buffer; } template<class T>