From e1fc51c3a1d944193032d8bb1d95741d090b6d3b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sun, 9 Oct 2011 16:41:04 +0000 Subject: checked in pd-0.43-1test4.src.tar.gz svn path=/trunk/; revision=15558 --- pd/src/d_misc.c | 2 +- pd/src/d_soundfile.c | 13 ++++++++----- pd/src/d_ugen.c | 6 ++++++ pd/src/g_editor.c | 4 ++-- pd/src/g_text.c | 4 +++- pd/src/m_binbuf.c | 15 +++++++++++++-- pd/src/m_imp.h | 2 +- pd/src/m_pd.h | 4 ++-- pd/src/s_inter.c | 41 +++++++++++++++++++++++++---------------- pd/src/s_main.c | 4 ---- pd/src/s_print.c | 18 ++++++++++-------- pd/src/s_stuff.h | 5 ++++- pd/src/s_watchdog.c | 8 ++++++-- 13 files changed, 81 insertions(+), 45 deletions(-) (limited to 'pd/src') diff --git a/pd/src/d_misc.c b/pd/src/d_misc.c index 444986ea..acb288b0 100644 --- a/pd/src/d_misc.c +++ b/pd/src/d_misc.c @@ -31,7 +31,7 @@ static t_int *print_perform(t_int *w) startpost("%s:", x->x_sym->s_name); for(i=0; ix_count--; diff --git a/pd/src/d_soundfile.c b/pd/src/d_soundfile.c index 8c350305..ef121e11 100644 --- a/pd/src/d_soundfile.c +++ b/pd/src/d_soundfile.c @@ -286,7 +286,8 @@ int open_soundfile_via_fd(int fd, int headersize, { long chunksize = swap4(((t_wavechunk *)buf)->wc_size, swap), seekto = headersize + chunksize + 8, seekout; - + if (seekto & 1) /* pad up to even number of bytes */ + seekto++; if (!strncmp(((t_wavechunk *)buf)->wc_id, "fmt ", 4)) { long commblockonset = headersize + 8; @@ -338,6 +339,8 @@ int open_soundfile_via_fd(int fd, int headersize, { long chunksize = swap4(((t_datachunk *)buf)->dc_size, swap), seekto = headersize + chunksize + 8, seekout; + if (seekto & 1) /* pad up to even number of bytes */ + seekto++; /* post("chunk %c %c %c %c seek %d", ((t_datachunk *)buf)->dc_id[0], ((t_datachunk *)buf)->dc_id[1], @@ -368,8 +371,8 @@ int open_soundfile_via_fd(int fd, int headersize, goto badheader; headersize = seekto; } - bytelimit = swap4(((t_datachunk *)buf)->dc_size, swap); - headersize += 8; + bytelimit = swap4(((t_datachunk *)buf)->dc_size, swap) - 8; + headersize += sizeof(t_datachunk); } } /* seek past header and any sample frames to skip */ @@ -784,7 +787,7 @@ static int create_soundfile(t_canvas *canvas, const char *filename, memcpy(&aiffhdr->a_nframeshi, &longtmp, 4); aiffhdr->a_bitspersamp = swap2(8 * bytespersamp, swap); memcpy(aiffhdr->a_samprate, dogdoo, sizeof(dogdoo)); - longtmp = swap4(datasize, swap); + longtmp = swap4(datasize + 8, swap); memcpy(aiffhdr->a_samprate + sizeof(dogdoo), &longtmp, 4); memset(aiffhdr->a_samprate + sizeof(dogdoo) + 4, 0, 8); headersize = AIFFPLUS; @@ -1327,7 +1330,7 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s, goto done; usage: pd_error(x, "usage: read [flags] filename tablename..."); - post("flags: -skip -nframes -resize -maxsize ..."); + post("flags: -skip -resize -maxsize ..."); post("-raw ."); done: if (fd >= 0) diff --git a/pd/src/d_ugen.c b/pd/src/d_ugen.c index 3fa7db54..1ed39600 100644 --- a/pd/src/d_ugen.c +++ b/pd/src/d_ugen.c @@ -617,6 +617,12 @@ t_dspcontext *ugen_start_graph(int toplevel, t_signal **sp, if (ugen_loud) post("ugen_start_graph..."); + /* protect against invalid numsignals + * this might happen if we have an abstraction with inlet~/outlet~ opened as a toplevel patch + */ + if(toplevel) + ninlets=noutlets=0; + dc->dc_ugenlist = 0; dc->dc_toplevel = toplevel; dc->dc_iosigs = sp; diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 89dd874c..f494732d 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -1916,8 +1916,8 @@ void canvas_menuclose(t_canvas *x, t_floatarg fforce) } else if (sys_perf) { - sys_vgui("pdtk_canvas_menuclose .x%lx {.x%lx menuclose 1;\n}\n", - canvas_getrootfor(g), g); + sys_vgui("pdtk_check .x%lx {Close this window?} {.x%lx menuclose 1;\n} yes\n", + canvas_getrootfor(x), x); } else pd_free(&x->gl_pd); } diff --git a/pd/src/g_text.c b/pd/src/g_text.c index a6e50491..d30b2ac9 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -170,6 +170,8 @@ static void canvas_howputnew(t_canvas *x, int *connectp, int *xpixp, int *ypixp, else { glist_getnextxy(x, xpixp, ypixp); + *xpixp -= 3; + *ypixp -= 3; glist_noselect(x); } *connectp = connectme; @@ -1371,10 +1373,10 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize) int xwas = x->te_xpix, ywas = x->te_ypix; glist_delete(glist, &x->te_g); canvas_objtext(glist, xwas, ywas, 0, b); + canvas_restoreconnections(glist_getcanvas(glist)); /* if it's an abstraction loadbang it here */ if (newest && pd_class(newest) == canvas_class) canvas_loadbang((t_canvas *)newest); - canvas_restoreconnections(glist_getcanvas(glist)); } /* if we made a new "pd" or changed a window name, update window list */ diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c index d109ae56..f0542d40 100644 --- a/pd/src/m_binbuf.c +++ b/pd/src/m_binbuf.c @@ -917,6 +917,13 @@ int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag) sys_unixerror(fbuf); goto fail; } + + if (fflush(f) != 0) + { + sys_unixerror(fbuf); + goto fail; + } + if (deleteit) binbuf_free(x); fclose(f); @@ -1477,7 +1484,7 @@ void binbuf_evalfile(t_symbol *name, t_symbol *dir) canvas_resume_dsp(dspstate); } -void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir) +t_pd *glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir) { t_pd *x = 0; /* even though binbuf_evalfile appears to take care of dspstate, @@ -1487,8 +1494,12 @@ void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir) int dspstate = canvas_suspend_dsp(); binbuf_evalfile(name, dir); - while ((x != s__X.s_thing) && (x = s__X.s_thing)) + while ((x != s__X.s_thing) && s__X.s_thing) + { + x = s__X.s_thing; vmess(x, gensym("pop"), "i", 1); + } pd_doloadbang(); canvas_resume_dsp(dspstate); + return x; } diff --git a/pd/src/m_imp.h b/pd/src/m_imp.h index d129bdbe..58468fd8 100644 --- a/pd/src/m_imp.h +++ b/pd/src/m_imp.h @@ -75,7 +75,7 @@ EXTERN int obj_siginletindex(t_object *x, int m); EXTERN int obj_sigoutletindex(t_object *x, int m); /* misc */ -EXTERN void glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir); +EXTERN t_pd *glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir); EXTERN void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv); EXTERN void glob_quit(void *dummy); #define __m_imp_h_ diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h index d04eae3a..4d9642fb 100644 --- a/pd/src/m_pd.h +++ b/pd/src/m_pd.h @@ -10,8 +10,8 @@ extern "C" { #define PD_MAJOR_VERSION 0 #define PD_MINOR_VERSION 43 -#define PD_BUGFIX_VERSION 0 -#define PD_TEST_VERSION "" +#define PD_BUGFIX_VERSION 1 +#define PD_TEST_VERSION "test4" /* 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/s_inter.c b/pd/src/s_inter.c index 6efa098c..99119983 100644 --- a/pd/src/s_inter.c +++ b/pd/src/s_inter.c @@ -1031,14 +1031,17 @@ int sys_startgui(const char *libdir) glob_t glob_buffer; char *homedir = getenv("HOME"); char embed_glob[FILENAME_MAX]; - char embed_filename[FILENAME_MAX], home_filename[FILENAME_MAX]; + char home_filename[FILENAME_MAX]; char *wish_paths[10] = { - "(did not find an embedded wish)", "(did not find a home directory)", "/Applications/Utilities/Wish.app/Contents/MacOS/Wish", "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell", "/Applications/Wish.app/Contents/MacOS/Wish", "/Applications/Wish Shell.app/Contents/MacOS/Wish Shell", + "/Library/Frameworks/Tk.framework/Resources/Wish.app/Contents/MacOS/Wish", + "/Library/Frameworks/Tk.framework/Resources/Wish Shell.app/Contents/MacOS/Wish Shell", + "/System/Library/Frameworks/Tk.framework/Resources/Wish.app/Contents/MacOS/Wish", + "/System/Library/Frameworks/Tk.framework/Resources/Wish Shell.app/Contents/MacOS/Wish Shell", "/usr/bin/wish" }; /* this glob is needed so the Wish executable can have the same @@ -1047,21 +1050,28 @@ int sys_startgui(const char *libdir) sprintf(embed_glob, "%s/../MacOS/Pd*", libdir); glob_buffer.gl_matchc = 1; /* we only need one match */ glob(embed_glob, GLOB_LIMIT, NULL, &glob_buffer); - if (glob_buffer.gl_pathc > 0) { - strcpy(embed_filename, glob_buffer.gl_pathv[0]); - wish_paths[0] = embed_filename; - } - sprintf(home_filename, - "%s/Applications/Wish.app/Contents/MacOS/Wish",homedir); - wish_paths[1] = home_filename; - for(i=0; i<10; i++) + /* If we are using a copy of Wish embedded in the Pd.app, then it + * will automatically load pd-gui.tcl if that embedded Wish can + * find ../Resources/Scripts/AppMain.tcl, then Wish doesn't want + * to receive the pd-gui.tcl as an argument. Otherwise it needs + * to know how to find pd-gui.tcl */ + if (glob_buffer.gl_pathc > 0) + sprintf(cmdbuf, "\"%s\" %d\n", glob_buffer.gl_pathv[0], portno); + else { - if (sys_verbose) - fprintf(stderr, "Trying Wish at \"%s\"\n", wish_paths[i]); - if (stat(wish_paths[i], &statbuf) >= 0) - break; + sprintf(home_filename, + "%s/Applications/Wish.app/Contents/MacOS/Wish",homedir); + wish_paths[0] = home_filename; + for(i=0; i<10; i++) + { + if (sys_verbose) + fprintf(stderr, "Trying Wish at \"%s\"\n", wish_paths[i]); + if (stat(wish_paths[i], &statbuf) >= 0) + break; + } + sprintf(cmdbuf, "\"%s\" \"%s/%spd-gui.tcl\" %d\n", + wish_paths[i], libdir, PDGUIDIR, portno); } - sprintf(cmdbuf,"\"%s\" %d\n", wish_paths[i], portno); #else /* __APPLE__ */ sprintf(cmdbuf, "TCL_LIBRARY=\"%s/lib/tcl/library\" TK_LIBRARY=\"%s/lib/tk/library\" \ @@ -1142,7 +1152,6 @@ int sys_startgui(const char *libdir) @audio - memlock unlimited in the system limits file, perhaps /etc/limits.conf or /etc/security/limits.conf */ - fprintf(stderr, "was... %d\n", sys_hipriority); if (sys_hipriority == -1) sys_hipriority = 1; diff --git a/pd/src/s_main.c b/pd/src/s_main.c index 24b5860e..119a629e 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -176,11 +176,7 @@ int sys_fontheight(int fontsize) } int sys_defaultfont; -#ifdef MSW -#define DEFAULTFONT 12 -#else #define DEFAULTFONT 10 -#endif static void openit(const char *dirname, const char *filename) { diff --git a/pd/src/s_print.c b/pd/src/s_print.c index c82601a1..6dbb6cfa 100644 --- a/pd/src/s_print.c +++ b/pd/src/s_print.c @@ -41,8 +41,8 @@ static char* strnescape(char *dest, const char *src, size_t len) static char* strnpointerid(char *dest, const void *pointer, size_t len) { *dest=0; - if(pointer) - snprintf(dest, len, ".x%lx", pointer); + if (pointer) + snprintf(dest, len, ".x%lx", (unsigned long)pointer); return dest; } @@ -280,13 +280,15 @@ void glob_finderror(t_pd *dummy) void glob_findinstance(t_pd *dummy, t_symbol*s) { - // revert s to (potential) pointer to object - void*obj=NULL; - if(sscanf(s->s_name, ".x%lx", &obj)) { - if(obj) { - canvas_finderror(obj); + // revert s to (potential) pointer to object + long obj = 0; + if (sscanf(s->s_name, ".x%lx", &obj)) + { + if (obj) + { + canvas_finderror((void *)obj); + } } - } } void bug(const char *fmt, ...) diff --git a/pd/src/s_stuff.h b/pd/src/s_stuff.h index b37b161a..03f42d38 100644 --- a/pd/src/s_stuff.h +++ b/pd/src/s_stuff.h @@ -290,7 +290,7 @@ void jack_listdevs(void); int mmio_open_audio(int naudioindev, int *audioindev, int nchindev, int *chindev, int naudiooutdev, int *audiooutdev, - int nchoutdev, int *choutdev, int rate); + int nchoutdev, int *choutdev, int rate, int blocksize); void mmio_close_audio( void); void mmio_reportidle(void); int mmio_send_dacs(void); @@ -375,6 +375,9 @@ EXTERN void sys_pollmidiqueue(void ); EXTERN int sys_pollgui(void ); EXTERN void sys_setchsr(int chin, int chout, int sr); +EXTERN void inmidi_realtimein(int portno, int cmd); +EXTERN void inmidi_byte(int portno, int byte); +EXTERN void inmidi_sysex(int portno, int byte); EXTERN void inmidi_noteon(int portno, int channel, int pitch, int velo); EXTERN void inmidi_controlchange(int portno, int channel, diff --git a/pd/src/s_watchdog.c b/pd/src/s_watchdog.c index 2602334d..d595773c 100644 --- a/pd/src/s_watchdog.c +++ b/pd/src/s_watchdog.c @@ -18,7 +18,7 @@ int main(int argc, char **argv) while (1) { struct timeval timout; - fd_set readset; + fd_set readset, exceptset; if (happy) { timout.tv_sec = 5; @@ -31,7 +31,11 @@ int main(int argc, char **argv) } FD_ZERO(&readset); FD_SET(0, &readset); - select(1, &readset, 0, 0, &timout); + FD_ZERO(&exceptset); + FD_SET(0, &exceptset); + select(1, &readset, 0, &exceptset, &timout); + if (FD_ISSET(0, &exceptset)) + return (0); if (FD_ISSET(0, &readset)) { char buf[100]; -- cgit v1.2.1