aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-01-08 04:58:31 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-01-08 04:58:31 +0000
commit0709ac9fabf4184675df1c3d8e205a2790adaadb (patch)
tree828916c3a4f0cde9641a4ed40961f5e7d56966be /externals/grill/flext/source
parentdad0b0542c08240f4431a34d46e6676461e0d83b (diff)
minor updates
adapted the queue stuff to work with the new set_callback functionality reconsidered flext::buffer:Update added object construction and destruction flags updated autoconf system small updates better templates, some minor changes update for linux cleanups svn path=/trunk/; revision=2476
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r--externals/grill/flext/source/flclass.h2
-rw-r--r--externals/grill/flext/source/fldsp.cpp25
-rw-r--r--externals/grill/flext/source/fldsp.h4
-rw-r--r--externals/grill/flext/source/flout.cpp2
-rwxr-xr-xexternals/grill/flext/source/flqueue.cpp50
-rw-r--r--externals/grill/flext/source/flstdc.h16
-rw-r--r--externals/grill/flext/source/flsupport.h4
7 files changed, 55 insertions, 48 deletions
diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h
index 7f19e6cf..edf8866c 100644
--- a/externals/grill/flext/source/flclass.h
+++ b/externals/grill/flext/source/flclass.h
@@ -854,7 +854,7 @@ private:
//! Start message queue
static void StartQueue();
-#ifdef FLEXT_QTHR
+#if FLEXT_QMODE == 2
//! Queue worker function
static void QWorker(thr_params *);
#endif
diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp
index 2384c5fe..f27ae032 100644
--- a/externals/grill/flext/source/fldsp.cpp
+++ b/externals/grill/flext/source/fldsp.cpp
@@ -48,17 +48,7 @@ flext_dsp::FLEXT_CLASSDEF(flext_dsp)():
#else
srate(sys_getsr()),blksz(sys_getblksize()),
#endif
-#if FLEXT_SYS == FLEXT_SYS_PD
- chnsin(sys_get_inchannels()),
- chnsout(sys_get_outchannels()),
-#elif FLEXT_SYS == FLEXT_SYS_MAX
- chnsin(0),chnsout(0),
-#elif FLEXT_SYS == FLEXT_SYS_JMAX
- #pragma message("not implemented")
chnsin(0),chnsout(0),
-#else
-#error
-#endif
#if FLEXT_SYS != FLEXT_SYS_MAX
dspon(true),
#endif
@@ -76,6 +66,9 @@ flext_dsp::~FLEXT_CLASSDEF(flext_dsp)()
fts_dsp_object_delete(thisHdr());
#endif
+ if(invecs) delete[] invecs;
+ if(outvecs) delete[] outvecs;
+
/*
#if FLEXT_SYS == FLEXT_SYS_MAX
// switch off dsp as the dsp function might get called afterwards (?!)
@@ -138,18 +131,6 @@ void flext_dsp::cb_dsp(t_class *c,t_signal **sp)
obj->blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ?
#endif
-/*
-#if FLEXT_SYS == FLEXT_SYS_PD
- obj->chnsin = sys_get_inchannels();
- obj->chnsout = sys_get_outchannels();
-#elif FLEXT_SYS == FLEXT_SYS_MAX
- obj->chnsin = obj->chnsout = sys_getch();
-#elif FLEXT_SYS == FLEXT_SYS_JMAX
- #pragma message ("How to query the channels?")
-#else
-#error
-#endif
-*/
// store in and out signal vectors
int i;
int in = obj->chnsin = obj->CntInSig();
diff --git a/externals/grill/flext/source/fldsp.h b/externals/grill/flext/source/fldsp.h
index 21a3aadb..80731848 100644
--- a/externals/grill/flext/source/fldsp.h
+++ b/externals/grill/flext/source/fldsp.h
@@ -50,7 +50,7 @@ public:
//! returns current block (aka vector) size
int Blocksize() const { return blksz; }
-
+
/*! \brief returns number of audio system input channels
\bug Doesn't work in Max/MSP - is always 0
*/
@@ -60,7 +60,7 @@ public:
\bug Doesn't work in Max/MSP - is always 0
*/
int ChannelsOut() const { return chnsout; }
-
+
//! typedef describing a signal vector
#if FLEXT_SYS == FLEXT_SYS_JMAX
typedef fts_symbol_t t_signalvec;
diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp
index c0d72ac7..70c940ef 100644
--- a/externals/grill/flext/source/flout.cpp
+++ b/externals/grill/flext/source/flout.cpp
@@ -62,7 +62,7 @@ void flext_base::ToSysAnything(int n,const t_symbol *s,int argc,const t_atom *ar
#endif
#if defined(FLEXT_THREADS)
- #if defined(FLEXT_QTHR)
+ #if FLEXT_QMODE == 2
#define CHKTHR() (IsSystemThread() || IsThread(flext::thrmsgid))
#else
#define CHKTHR() IsSystemThread()
diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp
index 9277887b..7c47cac6 100755
--- a/externals/grill/flext/source/flqueue.cpp
+++ b/externals/grill/flext/source/flqueue.cpp
@@ -25,7 +25,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
flext::thrid_t flext::thrmsgid = 0;
#endif
-
#define QUEUE_LENGTH 2048
#define QUEUE_ATOMS 8192
@@ -203,9 +202,9 @@ protected:
static Queue queue;
-#ifdef FLEXT_QTHR
+#if FLEXT_QMODE == 2
static flext::ThrCond qthrcond;
-#else
+#elif FLEXT_QMODE == 0
static t_qelem *qclk = NULL;
#endif
@@ -222,7 +221,7 @@ static void QWork(bool syslock)
int qc = queue.Count();
if(!qc) break;
- #ifdef FLEXT_QTHR
+ #if FLEXT_QMODE == 2
if(syslock) sys_lock();
#endif
@@ -232,14 +231,14 @@ static void QWork(bool syslock)
queue.Pop();
} // inner loop
- #ifdef FLEXT_QTHR
+ #if FLEXT_QMODE == 2
if(syslock) sys_unlock();
#endif
}
}
-#if !defined(FLEXT_QTHR)
+#if FLEXT_QMODE == 0
#if FLEXT_SYS == FLEXT_SYS_JMAX
static void QTick(fts_object_t *c,int winlet, fts_symbol_t s, int ac, const fts_atom_t *at)
{
@@ -252,6 +251,17 @@ static void QTick(flext_base *c)
#endif
QWork(false);
}
+
+#elif FLEXT_QMODE == 1
+static t_int QTick(t_int *)
+{
+ QWork(false);
+#ifdef FLEXT_SHARED
+ return 1;
+#else
+ return 0;
+#endif
+}
#endif
/*
@@ -273,23 +283,29 @@ void flext_base::QFlush(flext_base *th)
static void Trigger()
{
#if FLEXT_SYS == FLEXT_SYS_PD
- #ifdef FLEXT_QTHR
+ #if FLEXT_QMODE == 2
// wake up worker thread
qthrcond.Signal();
- #else
+ #elif FLEXT_QMODE == 1 && !defined(FLEXT_SHARED)
+ set_callback(QTick,NULL,0);
+ #elif FLEXT_QMODE == 0
clock_delay(qclk,0);
#endif
#elif FLEXT_SYS == FLEXT_SYS_MAX
- qelem_set(qclk);
+ #if FLEXT_QMODE == 0
+ qelem_set(qclk);
+ #endif
#elif FLEXT_SYS == FLEXT_SYS_JMAX
- // this is dangerous because there may be other timers on this object!
- fts_timebase_add_call(fts_get_timebase(), (fts_object_t *)thisHdr(), QTick, NULL, 0);
+ #if FLEXT_QMODE == 0
+ // this is dangerous because there may be other timers on this object!
+ fts_timebase_add_call(fts_get_timebase(), (fts_object_t *)thisHdr(), QTick, NULL, 0);
+ #endif
#else
#error Not implemented
#endif
}
-#ifdef FLEXT_QTHR
+#if FLEXT_QMODE == 2
void flext_base::QWorker(thr_params *)
{
thrmsgid = GetThreadId();
@@ -306,15 +322,17 @@ void flext_base::StartQueue()
if(started) return;
else started = true;
-#ifdef FLEXT_QTHR
+#if FLEXT_QMODE == 1
+#ifdef FLEXT_SHARED
+ set_callback(QTick,NULL,0);
+#endif
+#elif FLEXT_QMODE == 2
LaunchThread(QWorker,NULL);
-#else
-#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
+#elif FLEXT_QMODE == 0 && (FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX)
qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick));
#else
#error Not implemented!
#endif
-#endif
}
void flext_base::ToQueueBang(int o) const
diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h
index 7d912090..75e17d57 100644
--- a/externals/grill/flext/source/flstdc.h
+++ b/externals/grill/flext/source/flstdc.h
@@ -281,25 +281,33 @@ typedef t_symbol *t_symptr;
// ----- set message queue mode -----
-#undef FLEXT_QTHR
-
#if FLEXT_SYS == FLEXT_SYS_PD && PD_MINOR_VERSION >= 37
// for PD version >= 0.37test10 FLEXT_PDLOCK is standard
#undef FLEXT_PDLOCK
#define FLEXT_PDLOCK
#endif
-#ifdef FLEXT_PDLOCK
+#if FLEXT_SYS == FLEXT_SYS_PD && PD_MINOR_VERSION >= 38 && defined(PD_DEVEL_VERSION)
+ // use idle callback
+ #define FLEXT_QMODE 1
+#elif defined(FLEXT_PDLOCK)
// new PD thread locking functionality shall be used
#if FLEXT_SYS == FLEXT_SYS_PD
#ifdef FLEXT_THREADS
// can only be used with PD and threaded build
- #define FLEXT_QTHR
+ #define FLEXT_QMODE 2
+ #else
+ #define FLEXT_QMODE 0
#endif
#else
#error FLEXT_PDLOCK can only be defined with PD
#endif
+#else
+ #define FLEXT_QMODE 0
#endif
+#ifndef FLEXT_QMODE
+#error Internal error: Queueing mode not defined
+#endif
#endif
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index e7e284c4..71332f6b 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
-Copyright (c) 2001-2004 Thomas Grill (xovo@gmx.net)
+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.
@@ -225,7 +225,7 @@ public:
bool IsDirty() const;
//! Get symbol of buffer
- t_symbol *Symbol() const { return const_cast<t_symbol *>(sym); }
+ const t_symbol *Symbol() const { return sym; }
//! Get literal name of buffer
const char *Name() const { return sym?GetString(sym):""; }