commit b1149ed6e027437ad57bb360214417629a175d10
parent 5339191a6e54192e25283cfad942d28ad394dcde
Author: paulnasca <paulnasca>
Date: Thu, 30 Sep 2004 21:25:36 +0000
*** empty log message ***
Diffstat:
9 files changed, 95 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -719,6 +719,7 @@
- Adaugat installer pt. windows (cu NSIS)
29 Sep 2004 - Inceput sa scriu interfata utilizator pt. incepatori
30 Sep 2004 - Terminat de scris interfata utilizator pt. incepatori si se selecteaza la pornire modul dorit
-
+ - Adaugata posibilitatea de a compila cu suport jack si oss simultan si sa se aleaga runtime ce doresc (jack/oss)
+
diff --git a/src/Makefile b/src/Makefile
@@ -6,7 +6,13 @@ else
CXXFLAGS= -O0 -ggdb -Wall -Wpointer-arith -Wstrict-prototypes
endif
-CXXFLAGS += -DOS_$(OS_PORT) -D$(MIDIIN)MIDIIN -D$(AUDIOOUT)AUDIOOUT -DFFTW_VERSION_$(FFTW_VERSION) -DASM_F2I_$(ASM_F2I) `fltk-config --cflags`
+CXXFLAGS += -DOS_$(OS_PORT) -D$(MIDIIN)MIDIIN -DFFTW_VERSION_$(FFTW_VERSION) -DASM_F2I_$(ASM_F2I) `fltk-config --cflags`
+
+ifeq ($(AUDIOOUT),OSS_AND_JACK)
+ CXXFLAGS += -DOSSAUDIOOUT -DJACKAUDIOOUT
+else
+ CXXFLAGS += -D$(AUDIOOUT)AUDIOOUT
+endif
export CXXFLAGS
LIBS= -lm `fltk-config --ldflags` -lmxml -lz
@@ -36,6 +42,11 @@ LIBS+= -lwinmm
endif
+ifeq ($(AUDIOOUT),OSS_AND_JACK)
+CXXFLAGS += `pkg-config --cflags jack`
+LIBS+= `pkg-config --libs jack`
+endif
+
ifeq ($(AUDIOOUT),JACK)
CXXFLAGS += `pkg-config --cflags jack`
LIBS+= `pkg-config --libs jack`
diff --git a/src/Makefile.inc b/src/Makefile.inc
@@ -19,6 +19,8 @@ LINUX_MIDIIN=ALSA
#LINUX_MIDIIN=NONE
#Next line sets the audio output (OSS/JACK/PA)
+
+#LINUX_AUDIOOUT=OSS_AND_JACK
LINUX_AUDIOOUT=OSS
#LINUX_AUDIOOUT=NONE
#LINUX_AUDIOOUT=JACK
diff --git a/src/Misc/Config.C b/src/Misc/Config.C
@@ -117,9 +117,13 @@ Config::Config(){
cfg.bankRootDirList[0]=new char[MAX_STRING_SIZE];
sprintf(cfg.bankRootDirList[0],"./");
+#ifdef VSTAUDIOOUT
+ cfg.bankRootDirList[1]=new char[MAX_STRING_SIZE];
+ sprintf(cfg.bankRootDirList[1],"c:/Program Files/ZynAddSubFX/banks");
+#else
cfg.bankRootDirList[1]=new char[MAX_STRING_SIZE];
sprintf(cfg.bankRootDirList[1],"../banks");
-
+#endif
cfg.bankRootDirList[2]=new char[MAX_STRING_SIZE];
sprintf(cfg.bankRootDirList[2],"banks");
@@ -149,8 +153,13 @@ Config::Config(){
cfg.presetsDirList[0]=new char[MAX_STRING_SIZE];
sprintf(cfg.presetsDirList[0],"./");
- cfg.presetsDirList[1]=new char[MAX_STRING_SIZE];
- sprintf(cfg.presetsDirList[1],"../presets");
+#ifdef VSTAUDIOOUT
+ cfg.bankRootDirList[1]=new char[MAX_STRING_SIZE];
+ sprintf(cfg.bankRootDirList[1],"c:/Program Files/ZynAddSubFX/presets");
+#else
+ cfg.bankRootDirList[1]=new char[MAX_STRING_SIZE];
+ sprintf(cfg.bankRootDirList[1],"../presets");
+#endif
cfg.presetsDirList[2]=new char[MAX_STRING_SIZE];
sprintf(cfg.presetsDirList[2],"presets");
diff --git a/src/Output/JACK_RTaudiooutput.C b/src/Output/JACK_RTaudiooutput.C
@@ -50,7 +50,7 @@ pthread_mutex_t zyn_thread_lock=PTHREAD_MUTEX_INITIALIZER;
pthread_t bthr;
-void JACKaudiooutputinit(Master *master_){
+bool JACKaudiooutputinit(Master *master_){
jackmaster=master_;
jackclient=0;
char tmpstr[100];
@@ -73,7 +73,7 @@ void JACKaudiooutputinit(Master *master_){
if (jackclient==0) {
fprintf(stderr,"\nERROR: Cannot make a jack client (possible reasons: JACK server is not running or jackd is launched by root and zynaddsubfx by another user.).\n\n\n");
- exit(1);
+ return(false);
};
fprintf(stderr,"Internal SampleRate = %d\nJack Output SampleRate= %d\n",SAMPLE_RATE,jack_get_sample_rate(jackclient));
@@ -91,7 +91,7 @@ void JACKaudiooutputinit(Master *master_){
if (jack_activate(jackclient)){
fprintf(stderr,"Cannot activate jack client\n");
- exit(1);
+ return(false);
};
pthread_create(&bthr,NULL,thread_blocked,NULL);
@@ -100,6 +100,8 @@ void JACKaudiooutputinit(Master *master_){
jack_connect(jackclient,jack_port_name(outport_left),"alsa_pcm:out_1");
jack_connect(jackclient,jack_port_name(outport_right),"alsa_pcm:out_2");
*/
+
+ return(true);
};
void *thread_blocked(void *arg){
diff --git a/src/Output/JACKaudiooutput.C b/src/Output/JACKaudiooutput.C
@@ -31,7 +31,7 @@ int jackprocess(jack_nframes_t nframes,void *arg);
int jacksrate(jack_nframes_t nframes,void *arg);
void jackshutdown(void *arg);
-void JACKaudiooutputinit(Master *master_){
+bool JACKaudiooutputinit(Master *master_){
jackmaster=master_;
jackclient=0;
char tmpstr[100];
@@ -44,8 +44,8 @@ void JACKaudiooutputinit(Master *master_){
};
if (jackclient==0) {
- fprintf(stderr,"\nERROR: Cannot make a jack client (possible reasons: JACK server is not running or jackd is launched by root and zynaddsubfx by another user.).\n\n\n");
- exit(1);
+ fprintf(stderr,"\nERROR: Cannot make a jack client (possible reasons: JACK server is not running or jackd is launched by root and zynaddsubfx by another user.).\n");
+ return(false);
};
fprintf(stderr,"Internal SampleRate = %d\nJack Output SampleRate= %d\n",SAMPLE_RATE,jack_get_sample_rate(jackclient));
@@ -63,13 +63,14 @@ void JACKaudiooutputinit(Master *master_){
if (jack_activate(jackclient)){
fprintf(stderr,"Cannot activate jack client\n");
- exit(1);
+ return(false);
};
/*
jack_connect(jackclient,jack_port_name(outport_left),"alsa_pcm:out_1");
jack_connect(jackclient,jack_port_name(outport_right),"alsa_pcm:out_2");
*/
+ return(true);
};
int jackprocess(jack_nframes_t nframes,void *arg){
diff --git a/src/Output/JACKaudiooutput.h b/src/Output/JACKaudiooutput.h
@@ -38,7 +38,7 @@
-void JACKaudiooutputinit(Master *master_);
+bool JACKaudiooutputinit(Master *master_);
void JACKfinish();
#endif
diff --git a/src/Output/Makefile b/src/Output/Makefile
@@ -2,6 +2,10 @@ include ../Makefile.inc
objects=Recorder.o
+ifeq ($(AUDIOOUT),OSS_AND_JACK)
+objects+=OSSaudiooutput.o JACKaudiooutput.o
+endif
+
ifeq ($(AUDIOOUT),JACK)
objects+=JACKaudiooutput.o
endif
diff --git a/src/main.C b/src/main.C
@@ -63,14 +63,21 @@ MasterUI *ui;
pthread_t thr1,thr2,thr3,thr4;
Master *master;
int swaplr=0;//1 for left-right swapping
+bool usejackit=false;
#ifdef JACKAUDIOOUT
#include "Output/JACKaudiooutput.h"
-#elif JACK_RTAUDIOOUT
+#endif
+
+#ifdef JACK_RTAUDIOOUT
#include "Output/JACKaudiooutput.h"
-#elif PAAUDIOOUT
+#endif
+
+#ifdef PAAUDIOOUT
#include "Output/PAaudiooutput.h"
-#elif OSSAUDIOOUT
+#endif
+
+#ifdef OSSAUDIOOUT
#include "Output/OSSaudiooutput.h"
OSSaudiooutput *audioout;
#endif
@@ -120,9 +127,10 @@ void *thread1(void *arg){
#endif
/*
- * Wave output thread (if is not compiled for JACK, Portaudio and VST)
+ * Wave output thread (for OSS AUDIO out)
*/
-#if !(defined(JACKAUDIOOUT)||defined(JACK_RTAUDIOOUT)||defined(PAAUDIOOUT)||defined(VSTAUDIOOUT))
+#if defined(OSSAUDIOOUT)
+//!(defined(JACKAUDIOOUT)||defined(JACK_RTAUDIOOUT)||defined(PAAUDIOOUT)||defined(VSTAUDIOOUT))
void *thread2(void *arg){
REALTYPE outputl[SOUND_BUFFER_SIZE];
@@ -235,13 +243,26 @@ void initprogram(){
master=new Master();
master->swaplr=swaplr;
-#ifdef OSSAUDIOOUT
- audioout=new OSSaudiooutput();
-#elif JACKAUDIOOUT
- JACKaudiooutputinit(master);
-#elif JACK_RTAUDIOOUT
+#if defined(JACKAUDIOOUT)
+ if (usejackit) {
+ bool tmp=JACKaudiooutputinit(master);
+#if defined(OSSAUDIOOUT)
+ if (!tmp) printf("\nUsing OSS instead.\n");
+#else
+ if (!tmp) exit(1);
+#endif
+ usejackit=tmp;
+ };
+#endif
+#if defined(OSSAUDIOOUT)
+ if (!usejackit) audioout=new OSSaudiooutput();
+ else audioout=NULL;
+#endif
+
+#ifdef JACK_RTAUDIOOUT
JACKaudiooutputinit(master);
-#elif PAAUDIOOUT
+#endif
+#ifdef PAAUDIOOUT
PAaudiooutputinit(master);
#endif
@@ -266,7 +287,7 @@ void exitprogram(){
delete(audioout);
#endif
#ifdef JACKAUDIOOUT
- JACKfinish();
+ if (usejackit) JACKfinish();
#endif
#ifdef JACK_RTAUDIOOUT
JACKfinish();
@@ -310,7 +331,9 @@ void exitprogram(){
#ifndef VSTAUDIOOUT
int main(int argc, char *argv[]){
int noui=0;
-
+#ifdef JACKAUDIOOUT
+ usejackit=true;//use jack by default
+#endif
fprintf(stderr,"%s","\nZynAddSubFX - Copyright (c) 2002-2004 Nasca Octavian Paul\n");
fprintf(stderr,"Compiled: %s %s\n",__DATE__,__TIME__);
fprintf(stderr,"%s","This program is free software (GNU GPL v.2) and \n it comes with ABSOLUTELY NO WARRANTY.\n\n");
@@ -335,6 +358,7 @@ int main(int argc, char *argv[]){
{"dump",2,NULL,'D'},
{"swap",2,NULL,'S'},
{"no-gui",2,NULL,'U'},
+ {"not-use-jack",2,NULL,'A'},
{"help",2,NULL,'h'},
{0,0,0,0}
};
@@ -346,10 +370,10 @@ int main(int argc, char *argv[]){
while (1){
#ifdef OS_LINUX
- opt=getopt_long(argc,argv,"l:r:b:o:hSDU",opts,&option_index);
+ opt=getopt_long(argc,argv,"l:r:b:o:hSDUA",opts,&option_index);
char *optarguments=optarg;
#else
- opt=getopt(argc,argv,"l:r:b:o:hSDU",&option_index);
+ opt=getopt(argc,argv,"l:r:b:o:hSDUA",&option_index);
char *optarguments=&winoptarguments[0];
#endif
@@ -361,6 +385,13 @@ int main(int argc, char *argv[]){
break;
case 'U':noui=1;
break;
+ case 'A':
+#ifdef JACKAUDIOOUT
+#ifdef OSSAUDIOOUT
+ usejackit=false;
+#endif
+#endif
+ break;
case 'l':tmp=0;
if (optarguments!=NULL) {
snprintf(loadfile,1000,"%s",optarguments);
@@ -411,6 +442,9 @@ int main(int argc, char *argv[]){
fprintf(stderr,"%s"," -S , --swap\t\t\t\t swap Left <--> Right\n");
fprintf(stderr,"%s"," -D , --dump\t\t\t\t Dumps midi note ON/OFF commands\n");
fprintf(stderr,"%s"," -U , --no-gui\t\t\t\t Run ZynAddSubFX without user interface\n");
+#ifdef JACKAUDIOOUT
+ fprintf(stderr,"%s"," -A , --not-use-jack\t\t\t Use OSS/ALSA instead of JACK\n");
+#endif
#ifdef OS_WINDOWS
fprintf(stderr,"%s","\nWARNING: On Windows systems, only short comandline parameters works.\n");
fprintf(stderr,"%s"," eg. instead '--buffer-size=512' use '-b 512'\n");
@@ -435,8 +469,9 @@ int main(int argc, char *argv[]){
pthread_create(&thr1,NULL,thread1,NULL);
#endif
-#if !(defined(JACKAUDIOOUT)||defined(JACK_RTAUDIOOUT)||defined(PAAUDIOOUT)||defined(VSTAUDIOOUT))
- pthread_create(&thr2,NULL,thread2,NULL);
+#ifdef OSSAUDIOOUT
+//!(defined(JACKAUDIOOUT)||defined(JACK_RTAUDIOOUT)||defined(PAAUDIOOUT)||defined(VSTAUDIOOUT))
+ if (!usejackit) pthread_create(&thr2,NULL,thread2,NULL);
#endif
/*It is not working and I don't know why