aboutsummaryrefslogtreecommitdiff
path: root/pd/src
diff options
context:
space:
mode:
Diffstat (limited to 'pd/src')
-rw-r--r--pd/src/CHANGELOG.txt5
-rw-r--r--pd/src/g_canvas.c16
-rw-r--r--pd/src/m_class.c9
-rw-r--r--pd/src/m_pd.h2
-rw-r--r--pd/src/makefile.in2
-rw-r--r--pd/src/makefile.nt3
-rw-r--r--pd/src/notes.txt4
-rw-r--r--pd/src/s_audio.c8
-rw-r--r--pd/src/s_loader.c20
-rw-r--r--pd/src/s_main.c8
-rw-r--r--pd/src/s_midi_oss.c4
-rw-r--r--pd/src/s_stuff.h2
-rw-r--r--pd/src/u_pdreceive.c118
13 files changed, 112 insertions, 89 deletions
diff --git a/pd/src/CHANGELOG.txt b/pd/src/CHANGELOG.txt
index 9620a7fa..6d789171 100644
--- a/pd/src/CHANGELOG.txt
+++ b/pd/src/CHANGELOG.txt
@@ -2,6 +2,11 @@ This file describes implementation and API changes; stuff more visible to the
user appears in the "release notes" instead. See the bottom of this file
for original notes on source stype and organization.
+0.42.0
+
+changed definition of t_float, t_sample, t_floatarg so that they can be
+set via #defines (PD_FLOATTYPE, etc).
+
0.41.0
add support for callback-based audio I/O
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index c6481d28..3220360f 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -1338,7 +1338,7 @@ void canvas_savedeclarationsto(t_canvas *x, t_binbuf *b)
}
}
-static void canvas_completepath(char *from, char *to)
+static void canvas_completepath(char *from, char *to, int bufsize)
{
if (sys_isabsolutepath(from))
{
@@ -1346,12 +1346,12 @@ static void canvas_completepath(char *from, char *to)
}
else
{ // if not absolute path, append Pd lib dir
- strncpy(to, sys_libdir->s_name, FILENAME_MAX-4);
- to[FILENAME_MAX-3] = '\0';
+ strncpy(to, sys_libdir->s_name, bufsize-4);
+ to[bufsize-3] = '\0';
strcat(to, "/");
}
- strncat(to, from, FILENAME_MAX-strlen(to));
- to[FILENAME_MAX-1] = '\0';
+ strncat(to, from, bufsize-strlen(to));
+ to[bufsize-1] = '\0';
}
static void canvas_declare(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
@@ -1375,7 +1375,8 @@ static void canvas_declare(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
}
else if ((argc > i+1) && !strcmp(flag, "-stdpath"))
{
- canvas_completepath(atom_getsymbolarg(i+1, argc, argv)->s_name, strbuf);
+ canvas_completepath(atom_getsymbolarg(i+1, argc, argv)->s_name,
+ strbuf, MAXPDSTRING);
e->ce_path = namelist_append(e->ce_path, strbuf, 0);
i++;
}
@@ -1386,7 +1387,8 @@ static void canvas_declare(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
}
else if ((argc > i+1) && !strcmp(flag, "-stdlib"))
{
- canvas_completepath(atom_getsymbolarg(i+1, argc, argv)->s_name, strbuf);
+ canvas_completepath(atom_getsymbolarg(i+1, argc, argv)->s_name,
+ strbuf, MAXPDSTRING);
sys_load_lib(0, strbuf);
i++;
}
diff --git a/pd/src/m_class.c b/pd/src/m_class.c
index aa44022d..cd4fbb1c 100644
--- a/pd/src/m_class.c
+++ b/pd/src/m_class.c
@@ -769,19 +769,22 @@ badarg:
s->s_name, c->c_name->s_name);
}
+ /* convenience routine giving a stdarg interface to typedmess(). Only
+ ten args supported; it seems unlikely anyone will need more since
+ longer messages are likely to be programmatically generated anyway. */
void pd_vmess(t_pd *x, t_symbol *sel, char *fmt, ...)
{
va_list ap;
- t_atom arg[MAXPDARG], *at =arg;
+ t_atom arg[10], *at = arg;
int nargs = 0;
char *fp = fmt;
va_start(ap, fmt);
while (1)
{
- if (nargs > MAXPDARG)
+ if (nargs >= 10)
{
- pd_error(x, "pd_vmess: only %d allowed", MAXPDARG);
+ pd_error(x, "pd_vmess: only 10 allowed");
break;
}
switch(*fp++)
diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h
index f48a13b9..da6a7c66 100644
--- a/pd/src/m_pd.h
+++ b/pd/src/m_pd.h
@@ -11,7 +11,7 @@ extern "C" {
#define PD_MAJOR_VERSION 0
#define PD_MINOR_VERSION 42
#define PD_BUGFIX_VERSION 0
-#define PD_TEST_VERSION "test1"
+#define PD_TEST_VERSION "test3"
/* old name for "MSW" flag -- we have to take it for the sake of many old
"nmakefiles" for externs, which will define NT and not MSW */
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index b4ad8217..ab6209ff 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -158,6 +158,8 @@ externs:
make -C ../extra/lrshift~ @EXTERNTARGET@
make -C ../extra/pique @EXTERNTARGET@
make -C ../extra/sigmund~ @EXTERNTARGET@
+ make -C ../extra/pd~ @EXTERNTARGET@
+ make -C ../extra/stdout @EXTERNTARGET@
BINARYMODE=@binarymode@
diff --git a/pd/src/makefile.nt b/pd/src/makefile.nt
index addad543..1f2822ba 100644
--- a/pd/src/makefile.nt
+++ b/pd/src/makefile.nt
@@ -18,8 +18,6 @@ LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:libc \
$(LDIR)\setupapi.lib ..\bin\pthreadVC.lib \
$(LD2)\libcmt.lib $(LD2)\oldnames.lib
-# \
-
GLIB = $(LIB) ..\bin\tcl84.lib ..\bin\tk84.lib
CFLAGS = /nologo /W3 /DMSW /DNT /DPD /DPD_INTERNAL /DWIN32 /DWINDOWS /Ox \
-DPA_LITTLE_ENDIAN -DUSEAPI_MMIO -DUSEAPI_PORTAUDIO -D__i386__ -DPA19
@@ -58,7 +56,6 @@ SRCPA = $(PASRC)/common/pa_stream.c \
$(PASRC)/os/win/pa_win_hostapis.c \
$(PASRC)/os/win/pa_win_util.c \
$(PASRC)/hostapi/wmme/pa_win_wmme.c
-# $(PADIR)/pa_win_wdmks/pa_win_wdmks.c
SRCASIO = $(PADIR)/pa_asio/pa_asio.cpp
diff --git a/pd/src/notes.txt b/pd/src/notes.txt
index 8f94137f..e5c85dca 100644
--- a/pd/src/notes.txt
+++ b/pd/src/notes.txt
@@ -1,4 +1,6 @@
---------------- dolist --------------------
+done:
+
test:
compile on various versions of linux
windows:
@@ -115,6 +117,8 @@ sublists should display on parent if desired? (new drawing instruction)
test and debug list elements of templates
sublists seem not to handle canvas allocation right (get.pd->pointer.pd bug)
append doesn't do symbols yet.
+-n flag for drawnumbers
+non-clickable arrays (plus arrays that respond more easily than default)
more features:
diff --git a/pd/src/s_audio.c b/pd/src/s_audio.c
index f56ac0d6..9f4e2051 100644
--- a/pd/src/s_audio.c
+++ b/pd/src/s_audio.c
@@ -192,10 +192,6 @@ void sys_set_audio_settings(int naudioindev, int *audioindev, int nchindev,
int indevs = 0, outdevs = 0, canmulti = 0, cancallback = 0;
audio_getdevs(indevlist, &indevs, outdevlist, &outdevs, &canmulti,
&cancallback, MAXNDEV, DEVDESCSIZE);
- if (sys_externalschedlib)
- {
- return;
- }
if (rate < 1)
rate = DEFAULTSRATE;
@@ -426,7 +422,9 @@ void sys_reopen_audio( void)
chindev, naudiooutdev, audiooutdev, naudiooutdev, choutdev, rate);
else
#endif
- post("unknown audio API specified");
+ if (sys_audioapi == API_NONE)
+ ;
+ else post("unknown audio API specified");
if (outcome) /* failed */
{
audio_state = 0;
diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c
index aac50898..bc637dce 100644
--- a/pd/src/s_loader.c
+++ b/pd/src/s_loader.c
@@ -8,6 +8,8 @@
#ifdef UNISTD
#include <stdlib.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#endif
#ifdef MSW
#include <io.h>
@@ -247,7 +249,7 @@ int sys_run_scheduler(const char *externalschedlibname,
typedef int (*t_externalschedlibmain)(const char *);
t_externalschedlibmain externalmainfunc;
char filename[MAXPDSTRING];
- snprintf(filename, sizeof(filename), "%s.%s", externalschedlibname,
+ snprintf(filename, sizeof(filename), "%s%s", externalschedlibname,
sys_dllextent);
sys_bashfilename(filename, filename);
#ifdef MSW
@@ -256,18 +258,28 @@ int sys_run_scheduler(const char *externalschedlibname,
if (!ntdll)
{
post("%s: couldn't load external scheduler lib ", filename);
- return (0);
+ return (1);
}
externalmainfunc =
(t_externalschedlibmain)GetProcAddress(ntdll, "main");
}
#else
{
- void *dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
+ void *dlobj;
+ struct stat statbuf;
+ /* if first-choice file extent can't 'stat', go for second */
+ if (stat(filename, &statbuf) < 0)
+ {
+ snprintf(filename, sizeof(filename), "%s%s", externalschedlibname,
+ sys_dllextent2);
+ sys_bashfilename(filename, filename);
+ }
+ dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
if (!dlobj)
{
post("%s: %s", filename, dlerror());
- return (0);
+ fprintf(stderr, "dlopen failed for %s: %s\n", filename, dlerror());
+ return (1);
}
externalmainfunc = (t_externalschedlibmain)dlsym(dlobj,
"pd_extern_sched");
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index dcc3bed9..0bc5a191 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -50,7 +50,7 @@ int sys_nosleep = 0; /* skip all "sleep" calls and spin instead */
char *sys_guicmd;
t_symbol *sys_libdir;
-static t_symbol *sys_guidir;
+t_symbol *sys_guidir;
static t_namelist *sys_openlist;
static t_namelist *sys_messagelist;
static int sys_version;
@@ -392,6 +392,8 @@ static char *(usagemessage[]) = {
"-nrt -- don't use real-time priority\n",
#endif
"-nosleep -- spin, don't sleep (may lower latency on multi-CPUs)\n",
+"-schedlib <file> -- plug in external scheduler\n",
+"-extraflags <s> -- string argument to send schedlib\n",
};
static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
@@ -810,7 +812,7 @@ int sys_argparse(int argc, char **argv)
sys_listplease = 1;
argc--; argv++;
}
- else if (!strcmp(*argv, "-schedlib"))
+ else if (!strcmp(*argv, "-schedlib") && argc > 1)
{
sys_externalschedlib = 1;
strncpy(sys_externalschedlibname, argv[1],
@@ -818,7 +820,7 @@ int sys_argparse(int argc, char **argv)
argv += 2;
argc -= 2;
}
- else if (!strcmp(*argv, "-extraflags"))
+ else if (!strcmp(*argv, "-extraflags") && argc > 1)
{
sys_extraflags = 1;
strncpy(sys_extraflagsstring, argv[1],
diff --git a/pd/src/s_midi_oss.c b/pd/src/s_midi_oss.c
index 354dc0d5..e1f7c8c6 100644
--- a/pd/src/s_midi_oss.c
+++ b/pd/src/s_midi_oss.c
@@ -81,7 +81,7 @@ void sys_do_open_midi(int nmidiin, int *midiinvec,
if (outdevindex >= 0 && fd >= 0)
oss_midioutfd[outdevindex] = fd;
}
- if (devno == 1 && fd < 0)
+ if (devno == 0 && fd < 0)
{
sys_setalarm(1000000);
fd = open("/dev/midi", O_RDONLY | O_MIDIFLAG);
@@ -116,7 +116,7 @@ void sys_do_open_midi(int nmidiin, int *midiinvec,
int fd = oss_midioutfd[i];
char namebuf[80];
int devno = midioutvec[i];
- if (devno == 1 && fd < 0)
+ if (devno == 0 && fd < 0)
{
sys_setalarm(1000000);
fd = open("/dev/midi", O_WRONLY | O_MIDIFLAG);
diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h
index e53d3edc..3276b00b 100644
--- a/pd/src/s_stuff.h
+++ b/pd/src/s_stuff.h
@@ -49,6 +49,7 @@ EXTERN int sys_hostfontsize(int fontsize);
extern int sys_defaultfont;
extern t_symbol *sys_libdir; /* library directory for auxilliary files */
+extern t_symbol *sys_guidir; /* directory holding pd_gui (also pd, u_pdsend, etc) */
/* s_loader.c */
int sys_load_lib(t_canvas *canvas, char *filename);
@@ -172,6 +173,7 @@ void sys_setalarm(int microsec);
void sys_setvirtualalarm( void);
#endif
+#define API_NONE 0
#define API_ALSA 1
#define API_OSS 2
#define API_MMIO 3
diff --git a/pd/src/u_pdreceive.c b/pd/src/u_pdreceive.c
index 1feac305..e61397ed 100644
--- a/pd/src/u_pdreceive.c
+++ b/pd/src/u_pdreceive.c
@@ -2,10 +2,15 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in the Pd distribution. */
-/* the "pdreceive" command. This is a standalone program that receives messages
+/* the "pdreceive" command. This is a standalone program that receives messages
from Pd via the netsend/netreceive ("FUDI") protocol, and copies them to
standard output. */
+/* May 2008 : fixed a buffer overflow problem; pdreceive sometimes
+ repeated infinitely its buffer during high speed transfer.
+ Moonix::Antoine Rousseau
+*/
+
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
@@ -26,10 +31,10 @@ standard output. */
typedef struct _fdpoll
{
int fdp_fd;
- char *fdp_inbuf;
- int fdp_inhead;
- int fdp_intail;
- int fdp_udp;
+ char *fdp_outbuf;/*output message buffer*/
+ int fdp_outlen; /*length of output message*/
+ int fdp_discard;/*buffer overflow: output message is incomplete, discard it*/
+ int fdp_gotsemi;/*last char from input was a semicolon*/
} t_fdpoll;
static int nfdpoll;
@@ -122,8 +127,8 @@ static void addport(int fd)
fp->fdp_fd = fd;
nfdpoll++;
if (fd >= maxfd) maxfd = fd + 1;
- fp->fdp_inhead = fp->fdp_intail = 0;
- if (!(fp->fdp_inbuf = malloc(BUFSIZE)))
+ fp->fdp_outlen = fp->fdp_discard = fp->fdp_gotsemi = 0;
+ if (!(fp->fdp_outbuf = malloc(BUFSIZE)))
{
fprintf(stderr, "out of memory");
exit(1);
@@ -141,7 +146,7 @@ static void rmport(t_fdpoll *x)
if (fp == x)
{
x_closesocket(fp->fdp_fd);
- free(fp->fdp_inbuf);
+ free(fp->fdp_outbuf);
while (i--)
{
fp[0] = fp[1];
@@ -191,75 +196,66 @@ static void udpread(void)
}
}
-static int tcpmakeoutput(t_fdpoll *x)
+static int tcpmakeoutput(t_fdpoll *x, char *inbuf, int len)
{
- char messbuf[BUFSIZE+1], *bp = messbuf;
- int indx;
- int inhead = x->fdp_inhead;
- int intail = x->fdp_intail;
- char *inbuf = x->fdp_inbuf;
- if (intail == inhead)
- return (0);
- for (indx = intail; indx != inhead; indx = (indx+1)&(BUFSIZE-1))
+ int i;
+ int outlen = x->fdp_outlen;
+ char *outbuf = x->fdp_outbuf;
+
+ for (i = 0 ; i < len ; i++)
{
+ char c = inbuf[i];
+
+ if((c != '\n') || (!x->fdp_gotsemi))
+ outbuf[outlen++] = c;
+ x->fdp_gotsemi = 0;
+ if (outlen >= (BUFSIZE-1)) /*output buffer overflow; reserve 1 for '\n' */
+ {
+ fprintf(stderr, "pdreceive: message too long; discarding\n");
+ outlen = 0;
+ x->fdp_discard = 1;
+ }
/* search for a semicolon. */
- char c = *bp++ = inbuf[indx];
if (c == ';')
{
- intail = (indx+1)&(BUFSIZE-1);
- if (inbuf[intail] == '\n')
- intail = (intail+1)&(BUFSIZE-1);
- *bp++ = '\n';
-#ifdef MSW
+ outbuf[outlen++] = '\n';
+ if (!x->fdp_discard)
{
- int j;
- for (j = 0; j < bp - messbuf; j++)
- putchar(messbuf[j]);
- }
+#ifdef MSW
+ {
+ int j;
+ for (j = 0; j < outlen; j++)
+ putchar(outbuf[j]);
+ }
#else
- write(1, messbuf, bp - messbuf);
+ write(1, outbuf, outlen);
#endif
- x->fdp_inhead = inhead;
- x->fdp_intail = intail;
- return (1);
- }
- }
+ } /* if (!x->fdp_discard) */
+
+ outlen = 0;
+ x->fdp_discard = 0;
+ x->fdp_gotsemi = 1;
+ } /* if (c == ';') */
+ } /* for */
+
+ x->fdp_outlen = outlen;
return (0);
}
static void tcpread(t_fdpoll *x)
{
- int readto =
- (x->fdp_inhead >= x->fdp_intail ? BUFSIZE : x->fdp_intail-1);
- int ret;
+ int ret;
+ char inbuf[BUFSIZE];
- /* the input buffer might be full. If so, drop the whole thing */
- if (readto == x->fdp_inhead)
- {
- fprintf(stderr, "pd: dropped message from gui\n");
- x->fdp_inhead = x->fdp_intail = 0;
- readto = BUFSIZE;
- }
- else
+ ret = recv(x->fdp_fd, inbuf, BUFSIZE, 0);
+ if (ret < 0)
{
- ret = recv(x->fdp_fd, x->fdp_inbuf + x->fdp_inhead,
- readto - x->fdp_inhead, 0);
- if (ret < 0)
- {
- sockerror("recv (tcp)");
- rmport(x);
- }
- else if (ret == 0)
- rmport(x);
- else
- {
- x->fdp_inhead += ret;
- if (x->fdp_inhead >= BUFSIZE)
- x->fdp_inhead = 0;
- while (tcpmakeoutput(x))
- ;
- }
+ sockerror("recv (tcp)");
+ rmport(x);
}
+ else if (ret == 0)
+ rmport(x);
+ else tcpmakeoutput(x, inbuf, ret);
}
static void dopoll(void)