zynaddsubfx

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

commit 8157b0723235226ee21250edc57daeec8b3eedb3
parent b0dca54b64f7269fadd2a0ee4ac8eda3fd31ccc3
Author: fundamental <[email protected]>
Date:   Tue, 15 Dec 2009 14:29:06 -0500

Nio: default output and configuration work

- There is now a default output as selected by ccmake
- The OssEngine had an enable bug get fixed
- The OutMgr is now configured at compile time

Diffstat:
Msrc/CMakeLists.txt | 46++++++++++++++++++++--------------------------
Msrc/Nio/AlsaEngine.cpp | 13+++----------
Msrc/Nio/OssEngine.cpp | 4++++
Msrc/Nio/OutMgr.cpp | 20++++++++++++++++++--
Msrc/main.cpp | 8--------
5 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -3,6 +3,7 @@ find_package(zlib REQUIRED) find_package(fftw REQUIRED) find_package(MXML REQUIRED) #find_package(pthread REQUIRED) +#find_package(OSS) find_package(Alsa) find_package(JACK) find_package(PortAudio) @@ -15,16 +16,15 @@ find_package(OpenGL) #for FLTK # file, but either in in CMakeCache.txt before compile, or by passing # parameters directly into cmake using the -D flag. SET (FFTW_VERSION 3 CACHE STRING "Version number of FFTW") -SET (OutputModule alsa CACHE STRING "Output module, either alsa, nio, jack or portaudio") +SET (DefaultOutput oss CACHE STRING + "Default Output module: [null, alsa, oss, jack, portaudio]") SET (GuiModule fltk CACHE STRING "GUI module, either fltk, qt or off") SET (CompileTests OFF CACHE BOOL "whether tests should be compiled in or not") - -#change this to have defaults set by results of find_package -SET (AlsaEnable OFF CACHE BOOL +SET (AlsaEnable ${ALSA_FOUND} CACHE BOOL "Enable support for Advanced Linux Sound Architecture") -SET (JackEnable OFF CACHE BOOL +SET (JackEnable ${JACK_FOUND} CACHE BOOL "Enable support for JACK Audio Connection toolKit") -SET (OssEnable OFF CACHE BOOL +SET (OssEnable ${ALSA_FOUND} CACHE BOOL #TODO perhaps check for /dev/dsp "Enable support for Open Sound System") # Now, handle the incoming settings and set define flags/variables based @@ -42,43 +42,37 @@ else () message(STATUS "GUI module defaulting to off") endif() -#depricated block -if (OutputModule STREQUAL alsa AND ALSA_FOUND) - set(AlsaMidiOutput TRUE) -elseif(OutputModule STREQUAL jack AND JACK_FOUND) - set(JackOutput TRUE) -elseif(OutputModule STREQUAL portaudio AND PortAudio_FOUND) - set(PortAudioOutput TRUE) -elseif(OutputModule STREQUAL nio AND ALSA_FOUND) - set(NewIO TRUE) -else () - message(FATAL_ERROR "OutputModule must be either alsa, nio, jack or portaudio") +if (DefaultOutput STREQUAL alsa) + add_definitions(-DALSA_DEFAULT=1) +elseif(DefaultOutput STREQUAL oss) + add_definitions(-DOSS_DEFAULT=1) +elseif(DefaultOutput STREQUAL jack) + add_definitions(-DOSS_DEFAULT=1) endif() + +########### Settings dependant code ########### +# From here on, the setting variables have been prepared so concentrate +# on the actual compiling. + if(AlsaEnable) + list(APPEND AUDIO_LIBRARIES ${ASOUND_LIBRARY}) add_definitions(-DALSA=1) endif(AlsaEnable) if(JackEnable) add_definitions(-DJACK=1) endif(JackEnable) if(OssEnable) + add_definitions(-DOSSAUDIOOUT) + list(APPEND AUDIO_LIBRARIES ${ASOUND_LIBRARY}) add_definitions(-DOSS=1) endif(OssEnable) -########### Settings dependant code ########### -# From here on, the setting variables have been prepared so concentrate -# on the actual compiling. - if(AlsaMidiOutput) add_definitions(-DOSSAUDIOOUT) set(AUDIO_LIBRARIES ${AUDIO_LIBRARIES} ${ASOUND_LIBRARY}) endif() -if(NewIO) - add_definitions(-DNEW_IO) - set(AUDIO_LIBRARIES ${AUDIO_LIBRARIES} ${ASOUND_LIBRARY}) -endif() - if (CompileTests) ENABLE_TESTING() endif() diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp @@ -49,13 +49,6 @@ AlsaEngine::AlsaEngine(OutMgr *out) } - -bool AlsaEngine::openAudio() -{ - return true; -} - - //bool AlsaEngine::openMidi() //{ // midi.device = config.cfg.midiDevice; @@ -207,7 +200,7 @@ bool AlsaEngine::Start() int chk; pthread_attr_t attr; threadStop = false; - enable = true; + enabled = true; //if (NULL != audio.handle) //{ pthread_attr_init(&attr); @@ -225,7 +218,7 @@ bool AlsaEngine::Start() bail_out: cerr << "Error - bail out of AlsaEngine::Start()" << endl; - Close(); + Stop(); threadStop = true; return false; } @@ -234,7 +227,7 @@ bail_out: void AlsaEngine::Stop() { threadStop = true; - enable = false; + enabled = false; if (NULL != audio.handle && audio.pThread) if (pthread_cancel(audio.pThread)) diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -67,6 +67,7 @@ OssEngine::OssEngine(OutMgr *out) ioctl(snd_handle, SNDCTL_DSP_SPEED, &snd_samplerate); ioctl(snd_handle, SNDCTL_DSP_SAMPLESIZE, &snd_bitsize); ioctl(snd_handle, SNDCTL_DSP_SETFRAGMENT, &snd_fragment); + cerr << "hello?" << endl; } OssEngine::~OssEngine() @@ -88,6 +89,8 @@ bool OssEngine::Start() pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&pThread, &attr, _AudioThread, this); + cerr << "Starting?"; + enabled = true; return true; } @@ -95,6 +98,7 @@ bool OssEngine::Start() void OssEngine::Stop() { threadStop = true; + enabled = false; } //void OssEngine::Close() diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp @@ -4,6 +4,13 @@ #include "AudioOut.h" #include "../Misc/Master.h" #include "NulEngine.h" +#if OSS +#include "OssEngine.h" +#endif +#if ALSA +#include "AlsaEngine.h" +#endif + using namespace std; OutMgr *sysOut; @@ -23,13 +30,21 @@ OutMgr::OutMgr(Master *nmaster) outr = new REALTYPE[SOUND_BUFFER_SIZE]; outl = new REALTYPE[SOUND_BUFFER_SIZE]; - //conditional compiling + //conditional compiling mess (but contained) managedOuts["NULL"] = defaultOut = new NulEngine(this); #if OSS +#if OSS_DEFAULT + managedOuts["OSS"] = defaultOut = new OssEngine(this); +#else managedOuts["OSS"] = new OssEngine(this); #endif +#endif #if ALSA - managedOuts["ALSA"] = new ALSAEngine(this); +#if ALSA_DEFAULT + managedOuts["ALSA"] = defaultOut = new AlsaEngine(this); +#else + managedOuts["ALSA"] = new AlsaEngine(this); +#endif #endif }; @@ -40,6 +55,7 @@ OutMgr::~OutMgr() pthread_mutex_lock(&close_m); pthread_cond_wait(&close_cond, &close_m); pthread_mutex_unlock(&close_m); +#warning TODO deallocate Engines (or have possible issues) } void *_outputThread(void *arg) diff --git a/src/main.cpp b/src/main.cpp @@ -568,15 +568,7 @@ int main(int argc, char *argv[]) #endif //Output Bootstrapping - sysOut=NULL; sysOut = new OutMgr(master); - //if(sysOut); - //AudioOut *tmp = new NulEngine(sysOut); - //tmp->openAudio(); - //tmp->openAudio(); - //AudioOut *tmp = new OssEngine(sysOut); - //if(tmp) - // sysOut->add(tmp); sysOut->run();