zynaddsubfx

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

commit 38d40131046ecdd8cfe28adb80b9528bdbc811cb
parent f84d90dfec1bfc7c49068255937dc8314dbfd7c9
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Wed, 30 Dec 2009 15:12:25 -0500

Wav: Fixed crashes from WavEngine

Diffstat:
Msrc/Misc/Recorder.cpp | 5+++--
Msrc/Nio/WavEngine.cpp | 23+++++++++++++++--------
2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/Misc/Recorder.cpp b/src/Misc/Recorder.cpp @@ -64,6 +64,7 @@ void Recorder::stop() if(wave) { sysOut->remove(wave); + wave->Stop(); wave->Close(); delete wave; wave = NULL; //is this even needed? @@ -74,8 +75,8 @@ void Recorder::stop() void Recorder::pause() { status = 0; -// wave->Stop(); - sysOut->remove(wave); + wave->Stop(); + sysOut->remove(wave); } int Recorder::recording() diff --git a/src/Nio/WavEngine.cpp b/src/Nio/WavEngine.cpp @@ -69,6 +69,15 @@ void WavEngine::Stop() if(!enabled()) return; enabled = false; + + //put something in the queue + pthread_mutex_lock(&outBuf_mutex); + outBuf.push(Stereo<Sample>(Sample(1,0.0),Sample(1,0.0))); + pthread_mutex_unlock(&outBuf_mutex); + + //make sure it moves + pthread_cond_signal(&outBuf_cv); + pthread_mutex_unlock(&outBuf_mutex); pthread_join(pThread, NULL); } @@ -109,7 +118,7 @@ void WavEngine::Close() file = NULL; } pthread_mutex_unlock(&write_mutex); - + } //lazy getter @@ -145,7 +154,7 @@ T limit(T val, T min, T max) } void *WavEngine::AudioThread() -{ +{ short int *recordbuf_16bit = new short int [SOUND_BUFFER_SIZE*2]; int size = SOUND_BUFFER_SIZE; @@ -165,18 +174,16 @@ void *WavEngine::AudioThread() void WavEngine::write_stereo_samples(int nsmps, short int *smps) { pthread_mutex_lock(&write_mutex); - if(!file) - return; - fwrite(smps, nsmps, 4, file); + if(file) + fwrite(smps, nsmps, 4, file); pthread_mutex_unlock(&write_mutex); sampleswritten += nsmps; } void WavEngine::write_mono_samples(int nsmps, short int *smps) { - if(!file) - return; - fwrite(smps, nsmps, 2, file); + if(file) + fwrite(smps, nsmps, 2, file); sampleswritten += nsmps; }