Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2605/source
Modified Files: Makefile.am flbuf.cpp flstdc.h flsupport.h Log Message: build system for flext-based externals reconsidered flext::buffer:Update improved buffer handling added object construction and destruction flags updated autoconf system updated documentation updated build system
Index: flstdc.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flstdc.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** flstdc.h 5 Jan 2005 05:04:13 -0000 1.30 --- flstdc.h 6 Jan 2005 04:59:05 -0000 1.31 *************** *** 3,7 **** flext - C++ layer for Max/MSP and pd (pure data) externals
! Copyright (c) 2001-2004 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. --- 3,7 ---- flext - C++ layer for Max/MSP and pd (pure data) externals
! Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. *************** *** 122,125 **** --- 122,129 ---- // doesn't exist for OS9 #include "ext_critical.h" + #include "buffer.h" + #else + // for OS9 include "inofficial" header file + #include "flmspbuffer.h" #endif #include "z_dsp.h"
Index: Makefile.am =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 28 Oct 2004 04:01:40 -0000 1.2 --- Makefile.am 6 Jan 2005 04:59:05 -0000 1.3 *************** *** 4,8 **** #
! lib_LIBRARIES = libflext.a libflext_d.a libflext_t.a libflext_td.a
SRCS_FLEXT = \ --- 4,8 ---- #
! lib_LIBRARIES = libflext-pd_s.a libflext-pd_sd.a libflext-pd_t.a libflext-pd_td.a
SRCS_FLEXT = \ *************** *** 77,127 ****
# for static libraries we can use automake ! libflext_a_SOURCES = $(SRCS_FLEXT) ! libflext_d_a_SOURCES = $(SRCS_FLEXT) ! libflext_t_a_SOURCES = $(SRCS_FLEXT) ! libflext_td_a_SOURCES = $(SRCS_FLEXT)
! libflext_a_CXXFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ ! libflext_d_a_CXXFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG ! libflext_t_a_CXXFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ -DFLEXT_THREADS ! libflext_td_a_CXXFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG -DFLEXT_THREADS
! libflext_a_LDFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_d_a_LDFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_t_a_LDFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ -DFLEXT_THREADS \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_td_a_LDFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG -DFLEXT_THREADS \ $(patsubst %,-framework %,$(FRAMEWORKS))
# for shared libraries, we can't ... ! libflext_la_CXXFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ -DFLEXT_SHARED \ -DFLEXT_EXPORTS $(DEFS) ! libflext_d_la_CXXFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG -DFLEXT_SHARED \ -DFLEXT_EXPORTS $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) ! libflext_la_LDFLAGS = @DYNAMIC_LDFLAGS@ $(LIB_STK) $(LIB_SNDOBJ) $(LDFLAGS) \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_d_la_LDFLAGS = @DYNAMIC_LDFLAGS@ $(LIB_STK) $(LIB_SNDOBJ) $(LDFLAGS) $(patsubst %,-framework %,$(FRAMEWORKS))
! libflext_la_NAME = libflext.@SOEXT@ ! libflext_d_la_NAME = libflext_d.@SOEXT@
! all-local: $(libflext_la_NAME) $(libflext_d_la_NAME)
! $(libflext_la_NAME): $(patsubst %.cpp,libflext_la-%.o,$(SRCS_FLEXT)) ! $(CXX) -shared $(libflext_la_LDFLAGS) $(LIBS) -o $(libflext_la_NAME) $^
! libflext_la-%.o : %.cpp ! $(CXX) -shared -c $(libflext_la_CXXFLAGS) $< -o $@
! $(libflext_d_la_NAME): $(patsubst %.cpp,libflext_d_la-%.o,$(SRCS_FLEXT)) ! $(CXX) -shared $(libflext_d_la_LDFLAGS) $(LIBS) -o $(libflext_d_la_NAME) $^
! libflext_d_la-%.o: %.cpp ! $(CXX) -shared -c $(libflext_d_la_CXXFLAGS) $< -o $@
install-exec-local: ! $(libLIBRARIES_INSTALL) $(libflext_la_NAME) $(DESTDIR)$(libdir) ! $(libLIBRARIES_INSTALL) $(libflext_d_la_NAME) $(DESTDIR)$(libdir) \ No newline at end of file --- 77,128 ----
# for static libraries we can use automake ! libflext_pd_s_a_SOURCES = $(SRCS_FLEXT) ! libflext_pd_sd_a_SOURCES = $(SRCS_FLEXT) ! libflext_pd_t_a_SOURCES = $(SRCS_FLEXT) ! libflext_pd_td_a_SOURCES = $(SRCS_FLEXT)
! libflext_pd_s_a_CXXFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ ! libflext_pd_sd_a_CXXFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG ! libflext_pd_t_a_CXXFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ -DFLEXT_THREADS ! libflext_pd_td_a_CXXFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG -DFLEXT_THREADS
! libflext_pd_s_a_LDFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_pd_sd_a_LDFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_pd_t_a_LDFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ -DFLEXT_THREADS \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_pd_td_a_LDFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG -DFLEXT_THREADS \ $(patsubst %,-framework %,$(FRAMEWORKS))
# for shared libraries, we can't ... ! libflext_pd_la_CXXFLAGS = @OPT_FLAGS@ @INCLUDEDIR@ -DFLEXT_SHARED \ -DFLEXT_EXPORTS $(DEFS) ! libflext_pd_d_la_CXXFLAGS = @INCLUDEDIR@ -g -DFLEXT_DEBUG -DFLEXT_SHARED \ -DFLEXT_EXPORTS $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) ! libflext_pd_la_LDFLAGS = @DYNAMIC_LDFLAGS@ $(LIB_STK) $(LIB_SNDOBJ) $(LDFLAGS) \ $(patsubst %,-framework %,$(FRAMEWORKS)) ! libflext_pd_d_la_LDFLAGS = @DYNAMIC_LDFLAGS@ $(LIB_STK) $(LIB_SNDOBJ) $(LDFLAGS) $(patsubst %,-framework %,$(FRAMEWORKS))
! libflext_pd_la_NAME = libflext-pd.@SOEXT@ ! libflext_pd_d_la_NAME = libflext-pd_d.@SOEXT@
! all-local: $(libflext_pd_la_NAME) $(libflext_pd_d_la_NAME)
! $(libflext_pd_la_NAME): $(patsubst %.cpp,libflext_pd_la-%.o,$(SRCS_FLEXT)) ! $(CXX) $(libflext_pd_la_LDFLAGS) $(LIBS) -o $(libflext_pd_la_NAME) $^
! libflext_pd_la-%.o : %.cpp ! $(CXX) -c $(libflext_pd_la_CXXFLAGS) $< -o $@
! $(libflext_pd_d_la_NAME): $(patsubst %.cpp,libflext_pd_d_la-%.o,$(SRCS_FLEXT)) ! $(CXX) $(libflext_pd_d_la_LDFLAGS) $(LIBS) -o $(libflext_pd_d_la_NAME) $^
! libflext_pd_d_la-%.o: %.cpp ! $(CXX) -c $(libflext_pd_d_la_CXXFLAGS) $< -o $@
install-exec-local: ! $(libLIBRARIES_INSTALL) $(libflext_pd_la_NAME) $(DESTDIR)$(libdir) ! $(libLIBRARIES_INSTALL) $(libflext_pd_d_la_NAME) $(DESTDIR)$(libdir) !
Index: flbuf.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flbuf.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** flbuf.cpp 31 Dec 2004 04:58:29 -0000 1.19 --- flbuf.cpp 6 Jan 2005 04:59:05 -0000 1.20 *************** *** 3,7 **** flext - C++ layer for Max/MSP and pd (pure data) externals
! Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. --- 3,7 ---- flext - C++ layer for Max/MSP and pd (pure data) externals
! Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. *************** *** 17,24 **** #if FLEXT_SYS != FLEXT_SYS_JMAX
- #if FLEXT_SYS == FLEXT_SYS_MAX - #include "flmspbuffer.h" // include inofficial buffer.h - #endif - #if FLEXT_SYS == FLEXT_SYS_PD #define DIRTY_INTERVAL 0 // buffer dirty check in msec --- 17,20 ---- *************** *** 32,35 **** --- 28,36 ---- #endif
+ #if FLEXT_SYS == FLEXT_SYS_MAX + static const t_symbol *sym_buffer = flext::MakeSymbol("buffer~"); + static const t_symbol *sym_size = flext::MakeSymbol("size"); + #endif + flext::buffer::buffer(const t_symbol *bn,bool delayed): sym(NULL),data(NULL), *************** *** 101,108 **** #elif FLEXT_SYS == FLEXT_SYS_MAX if(sym->s_thing) { ! const _buffer *p = (const _buffer *)sym->s_thing;
! if(NOGOOD(p) || !p->b_valid) { ! post("buffer: buffer object '%s' no good",GetString(sym)); if(valid) ret = -2; } --- 102,111 ---- #elif FLEXT_SYS == FLEXT_SYS_MAX if(sym->s_thing) { ! const t_buffer *p = (const t_buffer *)sym->s_thing;
! FLEXT_ASSERT(!NOGOOD(p)); ! ! if(ob_sym(p) != sym_buffer) { ! post("buffer: object '%s' not valid",GetString(sym)); if(valid) ret = -2; } *************** *** 128,191 **** }
- bool flext::buffer::Valid() const - { - if(sym) { - #if FLEXT_SYS == FLEXT_SYS_PD - int frames1; - t_sample *data1; - return arr && garray_getfloatarray(arr, &frames1, &data1) != 0; - #elif FLEXT_SYS == FLEXT_SYS_MAX - const _buffer *p = (const _buffer *)sym->s_thing; - return p && p->b_valid; - #else - #error - #endif - } - else return false; - } - - bool flext::buffer::Update() { ! // if(!Ok()) return false;
! bool ok = false;
#if FLEXT_SYS == FLEXT_SYS_PD ! if(!sym || !arr) return data == NULL;
int frames1; t_sample *data1; if(!garray_getfloatarray(arr, &frames1, &data1)) { - frames = 0; data = NULL; chns = 0; ! ok = true; } else if(data != data1 || frames != frames1) { - frames = frames1; data = data1; ! ok = true; } #elif FLEXT_SYS == FLEXT_SYS_MAX ! if(!sym) return data == NULL; ! ! if(sym->s_thing) { ! const _buffer *p = (const _buffer *)sym->s_thing; if(data != p->b_samples || chns != p->b_nchans || frames != p->b_frames) { data = p->b_samples; chns = p->b_nchans; frames = p->b_frames; ! ok = true; } } #else #error not implemented #endif - return ok; }
void flext::buffer::Frames(int fr,bool keep,bool zero) { #if FLEXT_SYS == FLEXT_SYS_PD // is this function guaranteed to keep memory and set rest to zero? --- 131,229 ---- }
bool flext::buffer::Update() { ! FLEXT_ASSERT(sym);
! bool upd = false;
#if FLEXT_SYS == FLEXT_SYS_PD ! if(!arr) return data == NULL;
int frames1; t_sample *data1; if(!garray_getfloatarray(arr, &frames1, &data1)) { data = NULL; chns = 0; ! frames = 0; ! upd = true; } else if(data != data1 || frames != frames1) { data = data1; ! frames = frames1; ! upd = true; } #elif FLEXT_SYS == FLEXT_SYS_MAX ! const t_buffer *p = (const t_buffer *)sym->s_thing; ! if(p) { ! FLEXT_ASSERT(!NOGOOD(p) && ob_sym(p) == sym_buffer); ! if(data != p->b_samples || chns != p->b_nchans || frames != p->b_frames) { data = p->b_samples; chns = p->b_nchans; frames = p->b_frames; ! upd = true; } } + else { + // buffer~ has e.g. been renamed + data = NULL; + chns = 0; + frames = 0; + upd = true; + } + #else + #error not implemented + #endif + return upd; + } + + flext::buffer::lock_t flext::buffer::Lock() + { + FLEXT_ASSERT(sym); + #if FLEXT_SYS == FLEXT_SYS_PD + FLEXT_ASSERT(arr); + #if PD_MINOR_VERSION >= 38 && defined(PD_DEVEL_VERSION) + garray_lock(arr); + #endif + return false; + #elif FLEXT_SYS == FLEXT_SYS_MAX + t_buffer *p = (t_buffer *)sym->s_thing; + FLEXT_ASSERT(p); + #if defined(MAC_VERSION) || defined(WIN_VERSION) + long old = p->b_inuse; + p->b_inuse = 1; + return old; + #else + // undefined for OS9 + return 0; + #endif + #else + #error not implemented + #endif + } + + void flext::buffer::Unlock(flext::buffer::lock_t prv) + { + FLEXT_ASSERT(sym); + #if FLEXT_SYS == FLEXT_SYS_PD + FLEXT_ASSERT(arr); + #if PD_MINOR_VERSION >= 38 && defined(PD_DEVEL_VERSION) + garray_unlock(arr); + #endif + #elif FLEXT_SYS == FLEXT_SYS_MAX + t_buffer *p = (t_buffer *)sym->s_thing; + FLEXT_ASSERT(p); + #if defined(MAC_VERSION) || defined(WIN_VERSION) + // not for OS9 + p->b_inuse = prv; + #endif #else #error not implemented #endif }
void flext::buffer::Frames(int fr,bool keep,bool zero) { + FLEXT_ASSERT(sym); #if FLEXT_SYS == FLEXT_SYS_PD // is this function guaranteed to keep memory and set rest to zero? *************** *** 200,211 **** // copy buffer data to tmp storage tmp = (t_sample *)NewAligned(sz*sizeof(t_sample)); ! if(tmp) ! CopySamples(tmp,data,sz); ! else ! error("flext::buffer - not enough memory for keeping buffer~ contents"); }
t_atom msg; ! _buffer *buf = (_buffer *)sym->s_thing; // b_msr reflects buffer sample rate... is this what we want? // Max bug: adding half a sample to prevent roundoff errors.... --- 238,247 ---- // copy buffer data to tmp storage tmp = (t_sample *)NewAligned(sz*sizeof(t_sample)); ! FLEXT_ASSERT(tmp); ! CopySamples(tmp,data,sz); }
t_atom msg; ! t_buffer *buf = (t_buffer *)sym->s_thing; // b_msr reflects buffer sample rate... is this what we want? // Max bug: adding half a sample to prevent roundoff errors.... *************** *** 213,217 ****
SetFloat(msg,ms); ! ::typedmess((object *)buf,gensym("size"),1,&msg);
Update(); --- 249,253 ----
SetFloat(msg,ms); ! ::typedmess((object *)buf,(t_symbol *)sym_size,1,&msg);
Update(); *************** *** 249,280 **** void flext::buffer::Dirty(bool force) { ! if(sym) { #if FLEXT_SYS == FLEXT_SYS_PD ! if((!ticking) && (interval || force)) { ! ticking = true; ! cb_tick(this); // immediately redraw ! } ! else { ! if(force) clock_delay(tick,0); ! isdirty = true; ! } #elif FLEXT_SYS == FLEXT_SYS_MAX ! if(sym->s_thing) { ! _buffer *p = (_buffer *)sym->s_thing; ! ! if(NOGOOD(p)) { ! post("buffer: buffer object '%s' no good",sym->s_name); ! } ! else { ! p->b_modtime = gettime(); ! } ! } ! else { ! FLEXT_LOG1("buffer: symbol '%s' not defined",sym->s_name); ! } #else #error Not implemented #endif - } }
--- 285,305 ---- void flext::buffer::Dirty(bool force) { ! FLEXT_ASSERT(sym); #if FLEXT_SYS == FLEXT_SYS_PD ! if((!ticking) && (interval || force)) { ! ticking = true; ! cb_tick(this); // immediately redraw ! } ! else { ! if(force) clock_delay(tick,0); ! isdirty = true; ! } #elif FLEXT_SYS == FLEXT_SYS_MAX ! t_buffer *p = (t_buffer *)sym->s_thing; ! FLEXT_ASSERT(p && !NOGOOD(p)); ! p->b_modtime = gettime(); #else #error Not implemented #endif }
*************** *** 310,315 **** bool flext::buffer::IsDirty() const { #if FLEXT_SYS == FLEXT_SYS_PD ! if(!arr) return false; #ifdef FLEXT_PDBUFDIRTYTIME return isdirty || garray_updatetime(arr) > cleantime; --- 335,341 ---- bool flext::buffer::IsDirty() const { + FLEXT_ASSERT(sym); #if FLEXT_SYS == FLEXT_SYS_PD ! FLEXT_ASSERT(arr); #ifdef FLEXT_PDBUFDIRTYTIME return isdirty || garray_updatetime(arr) > cleantime; *************** *** 319,331 **** #endif #elif FLEXT_SYS == FLEXT_SYS_MAX ! if(!sym->s_thing) return false; ! ! _buffer *p = (_buffer *)sym->s_thing; ! #ifdef FLEXT_DEBUG ! if(NOGOOD(p)) { ! post("buffer: buffer object '%s' no good",sym->s_name); ! return false; ! } ! #endif return p->b_modtime > cleantime; #else --- 345,350 ---- #endif #elif FLEXT_SYS == FLEXT_SYS_MAX ! t_buffer *p = (t_buffer *)sym->s_thing; ! FLEXT_ASSERT(p && !NOGOOD(p)); return p->b_modtime > cleantime; #else
Index: flsupport.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** flsupport.h 17 Dec 2004 05:01:18 -0000 1.73 --- flsupport.h 6 Jan 2005 04:59:05 -0000 1.74 *************** *** 149,152 **** --- 149,161 ---- { public: + + #if FLEXT_SYS == FLEXT_SYS_PD + typedef bool lock_t; + #elif FLEXT_SYS == FLEXT_SYS_MAX + typedef long lock_t; + #else + #error Not implemented + #endif + /*! \brief Construct buffer. \param s: symbol name, can be NULL *************** *** 159,173 **** ~buffer();
! /*! \brief Check if the data is valid */ ! bool Ok() const { return sym != NULL && data != NULL; } ! /*! \brief Check if buffer is valid */ ! bool Valid() const; /*! \brief Check and update if the buffer has been changed (e.g. resized) */ bool Update(); /*! \brief Set to specified buffer. --- 168,208 ---- ~buffer();
! /*! \brief Check if the buffer is valid for use ! \note This must be true to use any of the other functions except set */ ! bool Ok() const { return sym && data; } ! /*! \brief Check if buffer content is valid (not in state of content change) ! \note buffer must be Ok() */ ! bool Valid() const ! { ! FLEXT_ASSERT(sym); ! #if FLEXT_SYS == FLEXT_SYS_PD ! return true; ! #elif FLEXT_SYS == FLEXT_SYS_MAX ! const t_buffer *p = (const t_buffer *)sym->s_thing; ! return p && p->b_valid; ! #else ! #error not implemented ! #endif ! } /*! \brief Check and update if the buffer has been changed (e.g. resized) + \note buffer must be Ok() */ bool Update(); + + /*! \brief Lock buffer + \return previous state (needed for Unlock) + \note buffer must be Ok() + */ + lock_t Lock(); + + /*! \brief Unlock buffer + \param prv: Previous state is returned by Lock() + \note buffer must be Ok() + */ + void Unlock(lock_t prv); /*! \brief Set to specified buffer.