zynaddsubfx

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

commit b0dca54b64f7269fadd2a0ee4ac8eda3fd31ccc3
parent 6eaa61f5beb86c64c57b3a20b33dd028ed76d9f5
Author: fundamental <[email protected]>
Date:   Mon, 14 Dec 2009 22:19:11 -0500

Nio: Deprecating old I/O functions

- Removal of Close() and openAudio() from AudioOut interface

Diffstat:
Msrc/Nio/AlsaEngine.cpp | 17+++++++----------
Msrc/Nio/AlsaEngine.h | 14--------------
Msrc/Nio/AudioOut.h | 5-----
Msrc/Nio/NulEngine.cpp | 11++---------
Msrc/Nio/NulEngine.h | 2--
Msrc/Nio/OssEngine.cpp | 16++++++++--------
Msrc/Nio/OssEngine.h | 2--
Msrc/Nio/OutMgr.cpp | 11++++-------
8 files changed, 21 insertions(+), 57 deletions(-)

diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp @@ -52,7 +52,6 @@ AlsaEngine::AlsaEngine(OutMgr *out) bool AlsaEngine::openAudio() { - OpenStuff(); return true; } @@ -89,13 +88,6 @@ bool AlsaEngine::openAudio() //} -void AlsaEngine::Close() -{ - Stop(); - snd_pcm_drain(handle); - snd_pcm_close(handle); -} - string AlsaEngine::audioClientName() { string name = "zynaddsubfx"; @@ -209,11 +201,13 @@ bool AlsaEngine::xrunRecover() } -bool AlsaEngine::Start(void) +bool AlsaEngine::Start() { + OpenStuff(); int chk; pthread_attr_t attr; threadStop = false; + enable = true; //if (NULL != audio.handle) //{ pthread_attr_init(&attr); @@ -237,13 +231,16 @@ bail_out: } -void AlsaEngine::Stop(void) +void AlsaEngine::Stop() { threadStop = true; + enable = false; if (NULL != audio.handle && audio.pThread) if (pthread_cancel(audio.pThread)) cerr << "Error, failed to cancel Alsa audio thread" << endl; + snd_pcm_drain(handle); + snd_pcm_close(handle); //if (NULL != midi.handle && midi.pThread) // if (pthread_cancel(midi.pThread)) // cerr << "Error, failed to cancel Alsa midi thread" << endl; diff --git a/src/Nio/AlsaEngine.h b/src/Nio/AlsaEngine.h @@ -37,11 +37,9 @@ class AlsaEngine : public AudioOut//, MidiIn AlsaEngine(OutMgr *out); ~AlsaEngine() { }; - bool openAudio(); //bool openMidi(); bool Start(); void Stop(); - void Close(); unsigned int getSamplerate() { return audio.samplerate; }; unsigned int getBuffersize() { return audio.period_size; }; @@ -70,8 +68,6 @@ class AlsaEngine : public AudioOut//, MidiIn snd_pcm_sframes_t (*pcmWrite)(snd_pcm_t *handle, const void *data, snd_pcm_uframes_t nframes); - /**Get the next sample for output.*/ - //const Stereo<Sample> getNext(); /**Interleave Samples. \todo move this to util*/ const short *interleave(const Stereo<Sample> smps) const; @@ -108,16 +104,6 @@ class AlsaEngine : public AudioOut//, MidiIn void RunStuff(); void OpenStuff(); - //bool threadStop; - - //outside audio interface - queue<Stereo<Sample> > outBuf; - const Sample * curSmp; - pthread_mutex_t outBuf_mutex; - pthread_cond_t outBuf_cv; - - OutMgr *manager; - }; #endif diff --git a/src/Nio/AudioOut.h b/src/Nio/AudioOut.h @@ -34,11 +34,6 @@ class AudioOut AudioOut(OutMgr *out); virtual ~AudioOut() {}; - //depricated - virtual bool openAudio()=0; - //depricated - virtual void Close()=0; - /**Start the Driver*/ virtual bool Start()=0; /**Stop the Driver*/ diff --git a/src/Nio/NulEngine.cpp b/src/Nio/NulEngine.cpp @@ -89,6 +89,7 @@ bool NulEngine::Start() { pthread_attr_t attr; threadStop = false; + enabled = true; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&pThread, &attr, _AudioThread, this); @@ -99,14 +100,6 @@ bool NulEngine::Start() void NulEngine::Stop() { threadStop = true; + enabled = false; } -void NulEngine::Close() -{ - Stop(); -} - -bool NulEngine::openAudio() -{ - return true; -} diff --git a/src/Nio/NulEngine.h b/src/Nio/NulEngine.h @@ -33,10 +33,8 @@ class NulEngine: public AudioOut NulEngine(OutMgr *out); ~NulEngine(); - bool openAudio(); bool Start(); void Stop(); - void Close(); protected: void *AudioThread(); diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -75,10 +75,10 @@ OssEngine::~OssEngine() delete [] smps; } -bool OssEngine::openAudio() -{ - return true; -} +//bool OssEngine::openAudio() +//{ +// return true; +//} bool OssEngine::Start() { @@ -97,10 +97,10 @@ void OssEngine::Stop() threadStop = true; } -void OssEngine::Close() -{ - Stop(); -} +//void OssEngine::Close() +//{ +// Stop(); +//} void *OssEngine::_AudioThread(void *arg) { diff --git a/src/Nio/OssEngine.h b/src/Nio/OssEngine.h @@ -36,10 +36,8 @@ class OssEngine: public AudioOut //the out is [-1.0 .. 1.0] /* smp_left[] and smp_right[] has the size of SOUND_BUFFER_SIZE */ - bool openAudio(); bool Start(); void Stop(); - void Close(); protected: void *AudioThread(); diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp @@ -49,14 +49,10 @@ void *_outputThread(void *arg) void *OutMgr::outputThread() { - //pthread_mutex_lock(&mutex); - //for(list<AudioOut*>::iterator itr = outs.begin(); itr != outs.end(); ++itr) - // (*itr)->Start(); - //pthread_mutex_unlock(&mutex); - if(!defaultOut->openAudio())//there should be a better failsafe + //open up the default output + if(!defaultOut->Start())//there should be a better failsafe cerr << "ERROR: The default Audio Output Failed to Open!" << endl; - defaultOut->Start(); //setup running=true; @@ -102,7 +98,8 @@ void *OutMgr::outputThread() cout << "output to "; for(map<string,AudioOut*>::iterator itr = managedOuts.begin(); itr != managedOuts.end(); ++itr) { - itr->second->out(smps); + if(itr->second->isEnabled()) + itr->second->out(smps); if(false) cout << itr->second << " "; }