aboutsummaryrefslogtreecommitdiff
path: root/pd/src
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2004-02-02 14:31:34 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2004-02-02 14:31:34 +0000
commit64c61824dc8bc2a83c03cd609bea77f374b6cfe5 (patch)
treeb4b1af154b0ab3eae382b2d9dd5b6304b0bb1030 /pd/src
parente3f67bd77b72fbaeb643792a2d1f9decddbccbbe (diff)
merged with version_0_37_1test6
svn path=/trunk/; revision=1310
Diffstat (limited to 'pd/src')
-rw-r--r--pd/src/build.bat42
-rw-r--r--pd/src/d_soundfile.c17
-rw-r--r--pd/src/g_editor.c2
-rw-r--r--pd/src/g_mycanvas.c12
-rw-r--r--pd/src/g_text.c2
-rw-r--r--pd/src/m_glob.c2
-rw-r--r--pd/src/m_sched.c2
-rw-r--r--pd/src/makefile14
-rw-r--r--pd/src/makefile.irix65
-rw-r--r--pd/src/notes.txt15
-rw-r--r--pd/src/s_audio.c8
-rw-r--r--pd/src/s_audio_alsa.c35
-rw-r--r--pd/src/s_audio_jack.c14
-rw-r--r--pd/src/s_audio_mmio.c58
-rw-r--r--pd/src/s_audio_oss.c2
-rw-r--r--pd/src/s_inter.c25
-rw-r--r--pd/src/s_main.c90
17 files changed, 196 insertions, 209 deletions
diff --git a/pd/src/build.bat b/pd/src/build.bat
deleted file mode 100644
index 15d65957..00000000
--- a/pd/src/build.bat
+++ /dev/null
@@ -1,42 +0,0 @@
-nmake
-cd ..
-cd extra
-
-del *.dll
-
-cd bonk~
-nmake pd_nt
-move bonk~.dll ..
-cd ..
-
-cd choice
-nmake pd_nt
-move choice.dll ..
-cd ..
-
-cd expr~
-nmake pd_nt
-move expr.dll ..
-cd ..
-
-cd fiddle~
-nmake pd_nt
-move fiddle~.dll ..
-cd ..
-
-cd loop~
-nmake pd_nt
-move loop~.dll ..
-cd ..
-
-cd lrshift~
-nmake pd_nt
-move lrshift~.dll ..
-cd ..
-
-cd pique
-nmake pd_nt
-move pique.dll ..
-cd ..
-
-
diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c
index 5752fade..f9b9d802 100644
--- a/pd/src/d_soundfile.c
+++ b/pd/src/d_soundfile.c
@@ -540,7 +540,7 @@ static int soundfiler_writeargparse(void *obj, int *p_argc, t_atom **p_argv,
}
else if (!strcmp(flag, "little"))
{
- endianness = 1;
+ endianness = 0;
argc -= 1; argv += 1;
}
else if (!strcmp(flag, "r") || !strcmp(flag, "rate"))
@@ -670,7 +670,7 @@ static int create_soundfile(t_canvas *canvas, const char *filename,
wavehdr->w_samplespersec = swap4(samplerate, swap);
wavehdr->w_navgbytespersec =
swap4((int)(samplerate * nchannels * bytespersamp), swap);
- wavehdr->w_nblockalign = swap2(bytespersamp, swap);
+ wavehdr->w_nblockalign = swap2(nchannels * bytespersamp, swap);
wavehdr->w_nbitspersample = swap2(8 * bytespersamp, swap);
strncpy(wavehdr->w_datachunkid, "data", 4);
wavehdr->w_datachunksize = swap4(datasize, swap);
@@ -729,6 +729,19 @@ static void soundfile_finishwrite(void *obj, char *filename, int fd,
if (write(fd, (char *)(&mofo), 4) < 4)
goto baddonewrite;
}
+ if (filetype == FORMAT_NEXT)
+ {
+ /* do it the lazy way: just set the size field to 'unknown size'*/
+ uint32 nextsize = 0xffffffff;
+ if (lseek(fd, 8, SEEK_SET) == 0)
+ {
+ goto baddonewrite;
+ }
+ if (write(fd, &nextsize, 4) < 4)
+ {
+ goto baddonewrite;
+ }
+ }
}
return;
baddonewrite:
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 74da81eb..48efb3ae 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -1434,6 +1434,8 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
SETSYMBOL(at+1, gotkeysym);
pd_list(keynamesym->s_thing, 0, 2, at);
}
+ if (!x->gl_editor) /* if that 'invis'ed the window, we'd better stop. */
+ return;
if (x && down)
{
/* if an object has "grabbed" keys just send them on */
diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c
index f723cff9..54e0ef07 100644
--- a/pd/src/g_mycanvas.c
+++ b/pd/src/g_mycanvas.c
@@ -316,13 +316,11 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
&&IS_A_FLOAT(argv,i+7)&&IS_A_FLOAT(argv,i+8)
&&IS_A_FLOAT(argv,i+9))
{
- if(IS_A_SYMBOL(argv,i+3))
- srl[2] = atom_getsymbolarg(i+3, argc, argv);
- else if(IS_A_FLOAT(argv,i+3))
- {
- sprintf(str, "%d", (int)atom_getintarg(i+3, argc, argv));
- srl[2] = gensym(str);
- }
+ /* disastrously, the "label" sits in a different part of the
+ message. So we have to track its location separately (in
+ the slot x_labelbindex) and initialize it specially here. */
+ iemgui_new_dogetname(&x->x_gui, i+3, argv);
+ x->x_gui.x_labelbindex = i+4;
ldx = (int)atom_getintarg(i+4, argc, argv);
ldy = (int)atom_getintarg(i+5, argc, argv);
iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(i+6, argc, argv));
diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 7fc2bbdf..1804c606 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -492,7 +492,7 @@ static void gatom_bang(t_gatom *x)
{
if (x->a_text.te_outlet)
outlet_symbol(x->a_text.te_outlet, x->a_atom.a_w.w_symbol);
- if (*x->a_symto->s_name && x->a_symto->s_thing)
+ if (*x->a_symto->s_name && x->a_expanded_to->s_thing)
{
if (x->a_symto == x->a_symfrom)
pd_error(x,
diff --git a/pd/src/m_glob.c b/pd/src/m_glob.c
index ba460aea..6c91feef 100644
--- a/pd/src/m_glob.c
+++ b/pd/src/m_glob.c
@@ -97,7 +97,7 @@ void glob_init(void)
gensym("start-path-dialog"), A_DEFFLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_path_dialog,
gensym("path-dialog"), A_GIMME, 0);
-#ifdef UNIX
+#ifdef __linux__
class_addmethod(glob_pdobject, (t_method)glob_ping, gensym("ping"), 0);
#endif
class_addanything(glob_pdobject, max_default);
diff --git a/pd/src/m_sched.c b/pd/src/m_sched.c
index 4020be06..552a89d0 100644
--- a/pd/src/m_sched.c
+++ b/pd/src/m_sched.c
@@ -265,7 +265,7 @@ static void sched_pollformeters( void)
/* if there's no GUI but we're running in "realtime", here is
where we arrange to ping the watchdog every 2 seconds. */
-#ifdef UNIX
+#ifdef __linux__
if (sys_nogui && sys_hipriority && (sched_diddsp - sched_nextpingtime > 0))
{
glob_ping(0);
diff --git a/pd/src/makefile b/pd/src/makefile
index b5c16ec6..40f1f2f3 100644
--- a/pd/src/makefile
+++ b/pd/src/makefile
@@ -14,17 +14,17 @@ MANDIR = ${prefix}/man
# ALSA compilation
-SOUND_ALSA =
+SOUND_ALSA = yes
DEFINES =
-MORECFLAGS = -DDL_OPEN -DUSEAPI_OSS
+MORECFLAGS = -DDL_OPEN -DUSEAPI_PORTAUDIO -DPA_USE_OSS -DPA_LITTLE_ENDIAN -DUSEAPI_OSS -I../portaudio/pa_common -I../portaudio/pablio -I../portaudio/portmidi-macosx -Werror
INCLUDE = -I.
-GINCLUDE = $(INCLUDE) -I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4 -I/usr/X11R6/include -I/usr/local/include
-GLIB = -lX11 -L/usr/X11R6/lib -L/usr/local/lib -ltcl84 -ltk84
+GINCLUDE = $(INCLUDE) -I/usr/include/tcl8.4
+GLIB = -ltk8.4 -ltcl8.4 -lX11 -L/usr/X11R6/lib -L/usr/local/lib
-LDFLAGS = -Wl,-export-dynamic -L/usr/local/lib/pth -lpthread
-LIB = -lm
+LDFLAGS = -Wl,-export-dynamic
+LIB = -ldl -lm -lpthread -lasound
#select either the DBG and OPT compiler flags below:
OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
@@ -63,7 +63,7 @@ endif
# the sources
-SYSSRC += s_midi_oss.c s_audio_oss.c
+SYSSRC += s_midi_oss.c s_audio_pa.c s_audio_oss.c ../portaudio/pa_common/pa_allocation.c ../portaudio/pa_common/pa_converters.c ../portaudio/pa_common/pa_cpuload.c ../portaudio/pa_common/pa_dither.c ../portaudio/pa_common/pa_front.c ../portaudio/pa_common/pa_process.c ../portaudio/pa_common/pa_skeleton.c ../portaudio/pa_common/pa_stream.c ../portaudio/pa_common/pa_trace.c ../portaudio/pablio/pablio_pd.c ../portaudio/pablio/ringbuffer_pd.c ../portaudio/pa_unix/pa_unix_hostapis.c ../portaudio/pa_unix/pa_unix_util.c ../portaudio/pa_unix_oss/pa_unix_oss.c
SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
diff --git a/pd/src/makefile.irix b/pd/src/makefile.irix
deleted file mode 100644
index 07975f04..00000000
--- a/pd/src/makefile.irix
+++ /dev/null
@@ -1,65 +0,0 @@
-# these can be altered from the command line to create an N32 version:
-# make EXECUTABLE=../bin/pd-n32 \
-XF1="-n32 -DN32 -woff 1080,1064,1185 -Ofast=ip32" \
-XF2="-OPT:cray_ivdep=true -r10000 -OPT:roundoff=3 -OPT:IEEE_arithmetic=3" pd
-
-EXECUTABLE=../bin/pd
-XF1=-o32 -fullwarn -O2
-XF2=
-all: $(EXECUTABLE) ../bin/pd-gui ../bin/pd.tk
-
-VPATH=../obj
-
-INCLUDE = -I. -I../../../irix/tk/generic -I../../../irix/tcl/generic
-GLIB = ../tk/unix/libtk8.0.a ../tcl/unix/libtcl8.0.a -lm -lX11
-LIB = -laudio -lmd -lm
-CFLAGS = -DUNIX -DIRIX -DPD $(XF1) $(XF2)
-LDFLAGS = $(XF1) $(XF2)
-
-SYSSRC = s_sgi.c
-
-SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \
- g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \
- g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \
- g_toggle.c g_vdial.c g_vslider.c g_vumeter.c \
- m_pd.c m_class.c m_obj.c m_atom.c m_memory.c m_binbuf.c \
- m_conf.c m_glob.c m_sched.c \
- s_main.c s_inter.c s_unix.c s_file.c s_print.c \
- s_loader.c s_path.c s_entry.c \
- d_ugen.c d_ctl.c d_arithmetic.c d_osc.c d_filter.c d_dac.c d_misc.c \
- d_math.c d_fft.c d_mayer_fft.c d_fftroutine.c d_array.c d_global.c \
- d_delay.c d_resample.c \
- x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \
- x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \
- $(SYSSRC)
-
-OBJ = $(SRC:.c=.o)
-
-GSRC = t_main.c t_tkcmd.c
-
-GOBJ = $(GSRC:.c=.o)
-.PHONY: pd gui
-
-.c.o:
- cc $(CFLAGS) $(INCLUDE) -c -o $(VPATH)/$*.o $*.c
-
-pd: $(EXECUTABLE)
-
-gui: ../bin/pd-gui
-
-$(EXECUTABLE): $(OBJ)
- cd ../obj; cc $(LDFLAGS) -o $(EXECUTABLE) $(OBJ) \
- $(LIB)
-
-../bin/pd-gui: $(GOBJ)
- cd ../obj; cc $(LDFLAGS) -o ../bin/pd-gui $(GOBJ) \
- $(GLIB) -lm -lX11
-
-../bin/pd.tk: u_main.tk; cp u_main.tk ../bin/pd.tk
-
-tags: $(SRC) $(GSRC); ctags *.[ch]
-
-depend:; cc -M $(CFLAGS) $(INCLUDE) $(SRC) > makefile.dependencies
-
-include makefile.dependencies
-
diff --git a/pd/src/notes.txt b/pd/src/notes.txt
index 6cd97820..a480f191 100644
--- a/pd/src/notes.txt
+++ b/pd/src/notes.txt
@@ -1,14 +1,17 @@
---------------- dolist --------------------
fix for 0.37:
-don't prepend help- if sethalpname is called
-Tom schouten: $HOME undefined crashes Pd
-update 'getting pd to run' to start in with dialog panels
-MIDI on windows?
+read xx.txt in "bad" gives warnings
+mess with RME ALSA some more; ALSA readn doesn't work yet.
+test MIDI I/O on all platforms, inc. sysex...
+windows quit doesn't confirm on Windows?
+check Pd in OSX 10.3
0.38:
-message dialog not to disappear
-sprout inlets/outlets on objects whose creation failed.
+document env~ second argument (and why is it no less than 1/10 of first???)
+make watchdog work for MACOSX
+%x to %lx in all "tags" to make 64-bit safe
+plug-in support
portaudio_pd files into src
GOP bounding box object
pd $1 bug ($1 is saved as it was evaluated, not as '$1')
diff --git a/pd/src/s_audio.c b/pd/src/s_audio.c
index 23c2197e..c08b42cb 100644
--- a/pd/src/s_audio.c
+++ b/pd/src/s_audio.c
@@ -40,7 +40,13 @@ static float sys_outmax; /* max output amplitude */
/* exported variables */
int sys_schedadvance; /* scheduler advance in microseconds */
float sys_dacsr;
+
+#ifdef MACOSX
+int sys_hipriority = 1;
+#else
int sys_hipriority = 0;
+#endif
+
t_sample *sys_soundout;
t_sample *sys_soundin;
@@ -326,6 +332,8 @@ else
}
sys_save_audio_params(naudioindev, audioindev, chindev,
naudiooutdev, audiooutdev, choutdev, rate, advance);
+ if (sys_inchannels == 0 && sys_outchannels == 0)
+ enable = 0;
audio_state = enable;
sys_vgui("set pd_whichapi %d\n", (audio_isopen() ? sys_audioapi : 0));
sched_set_using_dacs(enable);
diff --git a/pd/src/s_audio_alsa.c b/pd/src/s_audio_alsa.c
index b94a4e04..89c2d9de 100644
--- a/pd/src/s_audio_alsa.c
+++ b/pd/src/s_audio_alsa.c
@@ -663,6 +663,7 @@ void alsa_putzeros(int n)
post("result %d", result);
#endif
}
+ /* post ("putzeros %d", n); */
}
void alsa_getzeros(int n)
@@ -676,6 +677,7 @@ void alsa_getzeros(int n)
post("result %d", result);
#endif
}
+ /* post ("getzeros %d", n); */
}
/* call this only if both input and output are open */
@@ -713,7 +715,7 @@ static void alsa_checkiosync( void)
return;
}
defect = indelay + outdelay - alsa_buf_samps;
- if (defect < -DEFDACBLKSIZE)
+ if (defect < -(3 * DEFDACBLKSIZE / 2) )
{
checkit = 1;
alsa_putzeros(1);
@@ -727,13 +729,40 @@ static void alsa_checkiosync( void)
if (!alreadylogged)
sys_log_error(ERR_RESYNC), alreadylogged = 1;
}
+ /* if (alreadylogged)
+ post("in %d out %d defect %d", indelay, outdelay, defect); */
}
}
}
-void alsa_listdevs( void)
+static int alsa_nnames = 0;
+static char **alsa_names = 0;
+
+void alsa_adddev(char *name)
+{
+ if (alsa_nnames)
+ alsa_names = (char **)t_resizebytes(alsa_names,
+ alsa_nnames * sizeof(char *),
+ (alsa_nnames+1) * sizeof(char *));
+ else alsa_names = (char **)t_getbytes(sizeof(char *));
+ alsa_names[alsa_nnames] = gensym(name)->s_name;
+ alsa_nnames++;
+}
+
+static void alsa_numbertoname(int devno, char *devname, int nchar)
{
- post("device listing not implemented in ALSA yet\n");
+ int ndev = 0, cardno = -1;
+ while (!snd_card_next(&cardno) && cardno >= 0)
+ ndev++;
+ if (devno < 2*ndev)
+ {
+ if (devno & 1)
+ snprintf(devname, nchar, "plughw:%d", devno/2);
+ else snprintf(devname, nchar, "hw:%d", devno/2);
+ }
+ else if (devno <2*ndev + alsa_nnames)
+ snprintf(devname, nchar, "%s", alsa_names[devno - 2*ndev]);
+ else snprintf(devname, nchar, "???");
}
/* For each hardware card found, we list two devices, the "hard" and
diff --git a/pd/src/s_audio_jack.c b/pd/src/s_audio_jack.c
index 6f9937db..e9d8fcb5 100644
--- a/pd/src/s_audio_jack.c
+++ b/pd/src/s_audio_jack.c
@@ -54,13 +54,13 @@ process (jack_nframes_t nframes, void *arg)
}
jack_filled -= nframes;
} else { /* PD could not keep up ! */
- if (jack_started) sys_log_error(ERR_RESYNC);
- for (j = 0; j < sys_outchannels; j++) {
- out = jack_port_get_buffer (output_port[j], nframes);
- memset(out, 0, sizeof (float) * nframes);
- }
- memset(jack_outbuf,0,sizeof(jack_outbuf));
- jack_filled = 0;
+ if (jack_started) sys_log_error(ERR_RESYNC);
+ for (j = 0; j < outport_count; j++) {
+ out = jack_port_get_buffer (output_port[j], nframes);
+ memset(out, 0, sizeof (float) * nframes);
+ }
+ memset(jack_outbuf,0,sizeof(jack_outbuf));
+ jack_filled = 0;
}
pthread_cond_broadcast(&jack_sem);
return 0;
diff --git a/pd/src/s_audio_mmio.c b/pd/src/s_audio_mmio.c
index 9c088574..03fcaf69 100644
--- a/pd/src/s_audio_mmio.c
+++ b/pd/src/s_audio_mmio.c
@@ -32,7 +32,6 @@ int nt_realdacblksize;
#define MAXBUFFER 100 /* number of buffers in use at maximum advance */
#define DEFBUFFER 30 /* default is about 30x6 = 180 msec! */
static int nt_naudiobuffer = DEFBUFFER;
-
float sys_dacsr = DEFAULTSRATE;
static int nt_whichapi = API_MMIO;
@@ -113,16 +112,15 @@ static void wave_prep(t_sbuf *bp)
wh->reserved = 0;
}
-static int nt_inalloc[NAPORTS], nt_outalloc[NAPORTS];
static UINT nt_whichdac = WAVE_MAPPER, nt_whichadc = WAVE_MAPPER;
int mmio_do_open_audio(void)
{
PCMWAVEFORMAT form;
- int i;
+ int i, j;
UINT mmresult;
int nad, nda;
-
+ static int naudioprepped = 0, nindevsprepped = 0, noutdevsprepped = 0;
if (sys_verbose)
post("%d devices in, %d devices out",
nt_nwavein, nt_nwaveout);
@@ -136,6 +134,32 @@ int mmio_do_open_audio(void)
if (nt_nwavein <= 1 && nt_nwaveout <= 1)
nt_noresync();
+
+ if (nindevsprepped < nt_nwavein)
+ {
+ for (i = nindevsprepped; i < nt_nwavein; i++)
+ for (j = 0; j < nt_naudiobuffer; j++)
+ wave_prep(&ntsnd_invec[i][j]);
+ nindevsprepped = nt_nwavein;
+ }
+ if (noutdevsprepped < nt_nwaveout)
+ {
+ for (i = noutdevsprepped; i < nt_nwaveout; i++)
+ for (j = 0; j < nt_naudiobuffer; j++)
+ wave_prep(&ntsnd_outvec[i][j]);
+ noutdevsprepped = nt_nwaveout;
+ }
+ if (naudioprepped < nt_naudiobuffer)
+ {
+ for (j = naudioprepped; j < nt_naudiobuffer; j++)
+ {
+ for (i = 0; i < nt_nwavein; i++)
+ wave_prep(&ntsnd_invec[i][j]);
+ for (i = 0; i < nt_nwaveout; i++)
+ wave_prep(&ntsnd_outvec[i][j]);
+ }
+ naudioprepped = nt_naudiobuffer;
+ }
for (nad=0; nad < nt_nwavein; nad++)
{
/* Open waveform device(s), sucessively numbered, for input */
@@ -154,12 +178,6 @@ int mmio_do_open_audio(void)
}
else
{
- if (!nt_inalloc[nad])
- {
- for (i = 0; i < nt_naudiobuffer; i++)
- wave_prep(&ntsnd_invec[nad][i]);
- nt_inalloc[nad] = 1;
- }
for (i = 0; i < nt_naudiobuffer; i++)
{
mmresult = waveInPrepareHeader(ntsnd_indev[nad],
@@ -174,12 +192,11 @@ int mmio_do_open_audio(void)
}
}
/* quickly start them all together */
- for(nad=0; nad < nt_nwavein; nad++)
+ for (nad = 0; nad < nt_nwavein; nad++)
waveInStart(ntsnd_indev[nad]);
- for(nda=0; nda < nt_nwaveout; nda++)
- {
-
+ for (nda = 0; nda < nt_nwaveout; nda++)
+ {
/* Open a waveform device for output in sucessiv device numbering*/
mmresult = waveOutOpen(&ntsnd_outdev[nda], nt_whichdac + nda,
(WAVEFORMATEX *)(&form), 0L, 0L, CALLBACK_NULL);
@@ -194,19 +211,6 @@ int mmio_do_open_audio(void)
nt_waveouterror("waveOutOpen device: %s\n", mmresult);
nt_nwaveout = nda;
}
- else
- {
- if (!(nt_outalloc[nda]))
- {
- for (i = 0; i < nt_naudiobuffer; i++)
- {
- wave_prep(&ntsnd_outvec[nda][i]);
- /* set DONE flag as if we had queued them */
- ntsnd_outvec[nda][i].lpWaveHdr->dwFlags = WHDR_DONE;
- }
- nt_outalloc[nda] = 1;
- }
- }
}
return (0);
diff --git a/pd/src/s_audio_oss.c b/pd/src/s_audio_oss.c
index 05d7d26b..63fe0ed1 100644
--- a/pd/src/s_audio_oss.c
+++ b/pd/src/s_audio_oss.c
@@ -476,6 +476,8 @@ int oss_open_audio(int nindev, int *indev, int nchin, int *chin,
linux_dacs[i].d_nchannels * DEFDACBLKSIZE);
}
sys_setalarm(0);
+ sys_inchannels = inchannels;
+ sys_outchannels = outchannels;
return (0);
}
diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index d5beb866..8fa0cbd3 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -520,6 +520,7 @@ void sys_set_priority(int higher)
static int sys_watchfd;
+#ifdef __linux__
void glob_ping(t_pd *dummy)
{
if (write(sys_watchfd, "\n", 1) < 1)
@@ -528,6 +529,7 @@ void glob_ping(t_pd *dummy)
sys_bail(1);
}
}
+#endif
static int defaultfontshit[] = {
8, 5, 9, 10, 6, 10, 12, 7, 13, 14, 9, 17, 16, 10, 19, 24, 15, 28,
@@ -625,7 +627,10 @@ int sys_startgui(const char *guidir)
intarg = 1;
if (setsockopt(xsock, IPPROTO_TCP, TCP_NODELAY,
&intarg, sizeof(intarg)) < 0)
- post("setsockopt (TCP_NODELAY) failed\n");
+#ifndef MSW
+ post("setsockopt (TCP_NODELAY) failed\n")
+#endif
+ ;
server.sin_family = AF_INET;
@@ -732,7 +737,7 @@ int sys_startgui(const char *guidir)
#ifdef MSW
/* in MSW land "guipath" is unused; we just do everything from
the libdir. */
- fprintf(stderr, "%s\n", sys_libdir->s_name);
+ /* fprintf(stderr, "%s\n", sys_libdir->s_name); */
strcpy(scriptbuf, "\"");
strcat(scriptbuf, sys_libdir->s_name);
@@ -831,6 +836,7 @@ int sys_startgui(const char *guidir)
fprintf(stderr, "pd: couldn't set high priority class\n");
#endif
#ifdef MACOSX
+ if (sys_hipriority)
{
struct sched_param param;
int policy = SCHED_RR;
@@ -862,8 +868,10 @@ int sys_startgui(const char *guidir)
fprintf(stderr, "... connected\n");
/* here is where we start the pinging. */
+#ifdef __linux__
if (sys_hipriority)
sys_gui("pdtk_watchdog\n");
+#endif
sys_get_audio_apis(buf);
sys_vgui("pdtk_pd_startup {%s} %s\n", pd_version, buf);
}
@@ -883,7 +891,13 @@ int sys_pollgui(void)
return (sys_domicrosleep(0, 1) || sys_poll_togui());
}
-/* LATER try to save dirty documents */
+/* T.Grill - import clean quit function */
+extern void sys_exit(void);
+
+/* This is called when something bad has happened, like a segfault.
+Call glob_quit() below to exit cleanly.
+LATER try to save dirty documents even in the bad case. */
+
void sys_bail(int n)
{
static int reentered = 0;
@@ -897,7 +911,7 @@ void sys_bail(int n)
sys_close_midi();
fprintf(stderr, "... done.\n");
#endif
- exit(1);
+ exit(1);
}
else _exit(n);
}
@@ -906,7 +920,10 @@ void glob_quit(void *dummy)
{
sys_vgui("exit\n");
if (!sys_nogui)
+ {
close(sys_guisock);
+ sys_rmpollfn(sys_guisock);
+ }
sys_bail(0);
}
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index a7820026..9f038259 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -7,7 +7,7 @@
* 1311:forum::für::umläute:2001
*/
-char pd_version[] = "Pd version 0.37.0\n";
+char pd_version[] = "Pd version 0.37.1 TEST6 devel\n";
char pd_compiletime[] = __TIME__;
char pd_compiledate[] = __DATE__;
@@ -38,6 +38,7 @@ int sys_startgui(const char *guipath);
int sys_rcfile(void);
int m_scheduler(void);
void sys_addhelppath(char *p);
+void alsa_adddev(char *name);
int sys_debuglevel;
int sys_verbose;
@@ -227,8 +228,7 @@ void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
sys_messagelist = 0;
}
-static void sys_addextrapath(void);
-static void sys_addreferencepath(void);
+static void sys_afterargparse(void);
/* this is called from main() in s_entry.c */
int sys_main(int argc, char **argv)
@@ -241,9 +241,9 @@ int sys_main(int argc, char **argv)
#ifdef UNIX
sys_rcfile(); /* parse the startup file */
#endif
- if (sys_argparse(argc, argv)) return (1); /* parse cmd line */
- sys_addextrapath();
- sys_addreferencepath();
+ if (sys_argparse(argc, argv)) /* parse cmd line */
+ return (1);
+ sys_afterargparse(); /* post-argparse settings */
if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
pd_version, pd_compiletime, pd_compiledate);
if (sys_version) /* if we were just asked our version, exit here. */
@@ -286,6 +286,7 @@ static char *(usagemessage[]) = {
#ifdef USEAPI_ALSA
"-alsa -- use ALSA audio API\n",
+"-alsaadd <name> -- add an ALSA device name to list\n",
"-alsadev <n> ----- obsolete: use -audiodev\n",
#endif
@@ -328,8 +329,9 @@ static char *(usagemessage[]) = {
"-nogui -- suppress starting the GUI\n",
"-guicmd \"cmd...\" -- substitute another GUI program (e.g., rsh)\n",
"-send \"msg...\" -- send a message at startup (after patches are loaded)\n",
-#ifdef __linux__
-"-rt or -realtime -- use real-time priority (needs root privilege)\n",
+#ifdef UNIX
+"-rt or -realtime -- use real-time priority\n",
+"-nrt -- don't use real-time priority\n",
#endif
};
@@ -458,15 +460,16 @@ void sys_findprogdir(char *progname)
#endif
}
+#ifdef MSW
+static int sys_mmio = 1;
+#else
+static int sys_mmio = 0;
+#endif
+
int sys_argparse(int argc, char **argv)
{
char sbuf[MAXPDSTRING];
int i;
-#ifdef MSW
- int mmio = 1;
-#else
- int mmio = 0;
-#endif
argc--; argv++;
while ((argc > 0) && **argv == '-')
{
@@ -560,6 +563,13 @@ int sys_argparse(int argc, char **argv)
sys_set_audio_api(API_ALSA);
argc--; argv++;
}
+ else if (!strcmp(*argv, "-alsaadd"))
+ {
+ if (argc > 1)
+ alsa_adddev(argv[1]);
+ else goto usage;
+ argc -= 2; argv +=2;
+ }
/* obsolete flag for setting ALSA device number or name */
else if (!strcmp(*argv, "-alsadev"))
{
@@ -593,7 +603,7 @@ int sys_argparse(int argc, char **argv)
)
{
sys_set_audio_api(API_PORTAUDIO);
- mmio = 0;
+ sys_mmio = 0;
argc--; argv++;
}
#endif
@@ -601,7 +611,7 @@ int sys_argparse(int argc, char **argv)
else if (!strcmp(*argv, "-mmio"))
{
sys_set_audio_api(API_MMIO);
- mmio = 1;
+ sys_mmio = 1;
argc--; argv++;
}
#endif
@@ -719,6 +729,11 @@ int sys_argparse(int argc, char **argv)
sys_hipriority = 1;
argc--; argv++;
}
+ else if (!strcmp(*argv, "-nrt"))
+ {
+ sys_hipriority = 0;
+ argc--; argv++;
+ }
#endif
else if (!strcmp(*argv, "-soundindev") ||
!strcmp(*argv, "-audioindev"))
@@ -762,21 +777,6 @@ int sys_argparse(int argc, char **argv)
for (; argc > 0; argc--, argv++)
sys_openlist = namelist_append(sys_openlist, *argv);
- /* correct to make audio and MIDI device lists zero based. On
- MMIO, however, "1" really means the second device (the first one
- is "mapper" which is was not included when the command args were
- set up, so we leave it that way for compatibility. */
- if (!mmio)
- {
- for (i = 0; i < sys_nsoundin; i++)
- sys_soundindevlist[i]--;
- for (i = 0; i < sys_nsoundout; i++)
- sys_soundoutdevlist[i]--;
- }
- for (i = 0; i < sys_nmidiin; i++)
- sys_midiindevlist[i]--;
- for (i = 0; i < sys_nmidiout; i++)
- sys_midioutdevlist[i]--;
return (0);
}
@@ -786,22 +786,40 @@ int sys_getblksize(void)
return (DEFDACBLKSIZE);
}
-static void sys_addextrapath(void)
+ /* stuff to do, once, after calling sys_argparse() -- which may itself
+ be called twice because of the .pdrc hack. */
+static void sys_afterargparse(void)
{
char sbuf[MAXPDSTRING];
+ int i;
/* add "extra" library to path */
strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
sbuf[MAXPDSTRING-30] = 0;
strcat(sbuf, "/extra");
sys_addpath(sbuf);
-}
-
-static void sys_addreferencepath(void)
-{
- char sbuf[MAXPDSTRING];
/* add "doc/5.reference" library to helppath */
strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
sbuf[MAXPDSTRING-30] = 0;
strcat(sbuf, "/doc/5.reference");
sys_addhelppath(sbuf);
+ /* correct to make audio and MIDI device lists zero based. On
+ MMIO, however, "1" really means the second device (the first one
+ is "mapper" which is was not included when the command args were
+ set up, so we leave it that way for compatibility. */
+ if (!sys_mmio)
+ {
+ for (i = 0; i < sys_nsoundin; i++)
+ sys_soundindevlist[i]--;
+ for (i = 0; i < sys_nsoundout; i++)
+ sys_soundoutdevlist[i]--;
+ }
+ for (i = 0; i < sys_nmidiin; i++)
+ sys_midiindevlist[i]--;
+ for (i = 0; i < sys_nmidiout; i++)
+ sys_midioutdevlist[i]--;
+}
+
+static void sys_addreferencepath(void)
+{
+ char sbuf[MAXPDSTRING];
}