zynaddsubfx

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

commit be6389ad95bda3c412f30adf2772b4ae93992169
parent 0d9d6cd6c5286dffd1be0eeb663aabf6e41f6c48
Author: fundamental <[email protected]>
Date:   Tue, 29 Dec 2009 16:07:03 -0500

Nio: Giving Engines names

- Engines now have names
- A number of components have been simplified due to this factor

Diffstat:
Msrc/Nio/AlsaEngine.cpp | 1+
Msrc/Nio/Engine.h | 6++++--
Msrc/Nio/EngineMgr.cpp | 33+++++++++++++++------------------
Msrc/Nio/EngineMgr.h | 10++++++----
Msrc/Nio/JackEngine.cpp | 1+
Msrc/Nio/NulEngine.cpp | 1+
Msrc/Nio/OssEngine.cpp | 1+
Msrc/Nio/OutMgr.cpp | 4++--
Msrc/Nio/PaEngine.cpp | 4+++-
Msrc/UI/NioUI.cpp | 20++++++--------------
10 files changed, 40 insertions(+), 41 deletions(-)

diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp @@ -31,6 +31,7 @@ using namespace std; AlsaEngine::AlsaEngine(OutMgr *out) :AudioOut(out) { + name = "ALSA"; audio.handle = NULL; audio.period_time = 0; audio.samplerate = 0; diff --git a/src/Nio/Engine.h b/src/Nio/Engine.h @@ -1,10 +1,12 @@ #ifndef ENGINE_H #define ENGINE_H +#include <string> /**Marker for input/output driver*/ class Engine { public: - Engine(); - virtual ~Engine(); + Engine(); + virtual ~Engine(); + std::string name; }; #endif diff --git a/src/Nio/EngineMgr.cpp b/src/Nio/EngineMgr.cpp @@ -23,33 +23,33 @@ EngineMgr *sysEngine; EngineMgr::EngineMgr() { //conditional compiling mess (but contained) - engines["NULL"] = defaultEng = new NulEngine(sysOut); + engines.push_back(defaultEng = new NulEngine(sysOut)); #if OSS #if OSS_DEFAULT - engines["OSS"] = defaultEng = new OssEngine(sysOut); + engines.push_back(defaultEng = new OssEngine(sysOut)); #else - engines["OSS"] = new OssEngine(sysOut); + engines.push_back(new OssEngine(sysOut)); #endif #endif #if ALSA #if ALSA_DEFAULT - engines["ALSA"] = defaultEng = new AlsaEngine(sysOut); + engines.push_back(defaultEng = new AlsaEngine(sysOut)); #else - engines["ALSA"] = new AlsaEngine(sysOut); + engines.push_back(new AlsaEngine(sysOut)); #endif #endif #if JACK #if JACK_DEFAULT - engines["JACK"] = defaultEng = new JackEngine(sysOut); + engines.push_back(defaultEng = new JackEngine(sysOut)); #else - engines["JACK"] = new JackEngine(sysOut); + engines.push_back(new JackEngine(sysOut)); #endif #endif #if PORTAUDIO #if PORTAUDIO_DEFAULT - engines["PA"] = defaultEng = new PaEngine(sysOut); + engines.push_back(defaultEng = new PaEngine(sysOut)); #else - engines["PA"] = new PaEngine(sysOut); + engines.push_back(new PaEngine(sysOut)); #endif #endif @@ -57,24 +57,21 @@ EngineMgr::EngineMgr() EngineMgr::~EngineMgr() { - for(map<string, Engine*>::iterator itr = engines.begin(); + for(list<Engine*>::iterator itr = engines.begin(); itr != engines.end(); ++itr) { - delete itr->second; + delete *itr; } } Engine *EngineMgr::getEng(string name) { - Engine *ans = NULL; - transform(name.begin(), name.end(), name.begin(), ::toupper); - for(map<string, Engine*>::iterator itr = engines.begin(); + for(list<Engine*>::iterator itr = engines.begin(); itr != engines.end(); ++itr) { - if(itr->first == name) { - ans = itr->second; - break; + if((*itr)->name == name) { + return *itr; } } - return ans; + return NULL; } diff --git a/src/Nio/EngineMgr.h b/src/Nio/EngineMgr.h @@ -1,7 +1,7 @@ #ifndef ENGINE_MGR_H #define ENGINE_MGR_H -#include <map> +#include <list> #include <string> #include "Engine.h" @@ -9,7 +9,7 @@ class MidiIn; class AudioOut; class OutMgr; -/**Container/Owner of the long lived Engines*/ +/**Container/Owner of the long lived Engines*/ class EngineMgr { public: @@ -21,14 +21,16 @@ class EngineMgr * @return pointer to Engine or NULL */ Engine *getEng(std::string name); - + private: - std::map<std::string,Engine *> engines; + std::list<Engine *> engines; Engine *defaultEng;/**<The default output*/ //Engine Manager user + //[if there is another 'user, just make this class a struct] friend class OutMgr; + friend class NioUI; }; extern EngineMgr *sysEngine; diff --git a/src/Nio/JackEngine.cpp b/src/Nio/JackEngine.cpp @@ -33,6 +33,7 @@ using namespace std; JackEngine::JackEngine(OutMgr *out) :AudioOut(out), jackClient(NULL) { + name = "JACK"; audio.jackSamplerate = 0; audio.jackNframes = 0; for (int i = 0; i < 2; ++i) diff --git a/src/Nio/NulEngine.cpp b/src/Nio/NulEngine.cpp @@ -30,6 +30,7 @@ using namespace std; NulEngine::NulEngine(OutMgr *out) :AudioOut(out) { + name = "NULL"; playing_until.tv_sec = 0; playing_until.tv_usec = 0; } diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -39,6 +39,7 @@ using namespace std; OssEngine::OssEngine(OutMgr *out) :AudioOut(out) { + name = "OSS"; snd_fragment = 0x00080009; //fragment size (?) snd_stereo = 1; //stereo snd_format = AFMT_S16_LE; diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp @@ -94,9 +94,9 @@ void *OutMgr::outputThread() pthread_mutex_lock(&mutex); - for(map<string, Engine*>::iterator itr = sysEngine->engines.begin(); + for(list<Engine*>::iterator itr = sysEngine->engines.begin(); itr != sysEngine->engines.end(); ++itr) { - AudioOut *out = dynamic_cast<AudioOut *>(itr->second); + AudioOut *out = dynamic_cast<AudioOut *>(*itr); if(out && out->isEnabled()) out->out(smps); } diff --git a/src/Nio/PaEngine.cpp b/src/Nio/PaEngine.cpp @@ -28,7 +28,9 @@ using namespace std; PaEngine::PaEngine(OutMgr *out) :AudioOut(out) -{} +{ + name = "PA"; +} PaEngine::~PaEngine() diff --git a/src/UI/NioUI.cpp b/src/UI/NioUI.cpp @@ -1,5 +1,5 @@ #include "NioUI.h" -#include "../Nio/OutMgr.h" +#include "../Nio/EngineMgr.h" #include "../Nio/AudioOut.h" #include <cstdio> #include <FL/Fl_Tabs.H> @@ -29,19 +29,11 @@ NioUI::NioUI() intro->wrap_mode(4, 40); } gen->end(); -#if OSS - tabs.push_back(new NioTab("OSS")); -#endif -#if ALSA - tabs.push_back(new NioTab("ALSA")); -#endif -#if JACK - tabs.push_back(new NioTab("JACK")); -#endif -#if PORTAUDIO - tabs.push_back(new NioTab("PA")); -#endif - tabs.push_back(new NioTab("NULL")); + + for(list<Engine *>::iterator itr = sysEngine->engines.begin(); + itr != sysEngine->engines.end(); ++itr) + tabs.push_back(new NioTab((*itr)->name)); + //add tabs for(list<NioTab *>::iterator itr = tabs.begin(); itr != tabs.end(); ++itr)