From f688c9de1efee2e09fbb9b39a715853b23fadcb3 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Fri, 17 Dec 2004 05:01:18 +0000 Subject: global system lock functions fixed a thread sensitive spot fix for _long_ attribute dialogs build system for flext-based externals typo fixed in attribute editor atom outlet functions svn path=/trunk/; revision=2394 --- externals/grill/flext/source/flclass.h | 10 ++++++++ externals/grill/flext/source/flout.cpp | 24 +++++++++++++++++++ externals/grill/flext/source/flqueue.cpp | 41 +++++++++++++++++++++++++++++--- externals/grill/flext/source/flstdc.h | 1 + externals/grill/flext/source/flsupport.h | 29 +++++++++++++++++++--- 5 files changed, 99 insertions(+), 6 deletions(-) (limited to 'externals/grill/flext/source') diff --git a/externals/grill/flext/source/flclass.h b/externals/grill/flext/source/flclass.h index 12f274bd..7f19e6cf 100644 --- a/externals/grill/flext/source/flclass.h +++ b/externals/grill/flext/source/flclass.h @@ -231,6 +231,9 @@ public: //! Output string aka symbol (index n starts with 0) void ToOutString(int n,const char *s) const { ToOutSymbol(n,MakeSymbol(s)); } + //! Output atom (index n starts with 0) + void ToOutAtom(int n,const t_atom &at) const; + //! Output list (index n starts with 0) void ToOutList(int n,int argc,const t_atom *argv) const; //! Output list (index n starts with 0) @@ -264,6 +267,9 @@ public: //! Output string aka symbol (to appointed outlet) void ToQueueString(int n,const char *s) const { ToQueueSymbol(n,MakeSymbol(s)); } + //! Output atom (index n starts with 0) + void ToQueueAtom(int n,const t_atom &at) const; + //! Output list (index n starts with 0) void ToQueueList(int n,int argc,const t_atom *argv) const; //! Output list (index n starts with 0) @@ -292,6 +298,9 @@ public: //! Send string aka symbol to self (inlet 0) void ToSelfString(int n,const char *s) const { ToSelfSymbol(n,MakeSymbol(s)); } + //! Output atom (index n starts with 0) + void ToSelfAtom(int n,const t_atom &at) const { ToQueueAtom(-1-n,at); } + //! Send list to self (inlet n) void ToSelfList(int n,int argc,const t_atom *argv) const { ToQueueList(-1-n,argc,argv); } //! Send list to self (inlet n) @@ -736,6 +745,7 @@ protected: void ToSysInt(int n,int f) const; void ToSysBool(int n,bool f) const { ToSysInt(n,f?1:0); } void ToSysSymbol(int n,const t_symbol *s) const; + void ToSysAtom(int n,const t_atom &at) const; void ToSysList(int n,int argc,const t_atom *argv) const; void ToSysAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const; diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index 922dc59f..c0d72ac7 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -25,6 +25,29 @@ void flext_base::ToSysSymbol(int n,const t_symbol *s) const { outlet *o = GetOut void flext_base::ToSysList(int n,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_list((t_outlet *)o,const_cast(sym_list),argc,(t_atom *)argv); CRITOFF(); } } void flext_base::ToSysAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { outlet *o = GetOut(n); if(o) { CRITON(); outlet_anything((t_outlet *)o,const_cast(s),argc,(t_atom *)argv); CRITOFF(); } } +void flext_base::ToSysAtom(int n,const t_atom &at) const +{ + outlet *o = GetOut(n); + if(o) { + CRITON(); + if(IsSymbol(at)) + outlet_symbol((t_outlet *)o,const_cast(GetSymbol(at))); + else if(IsFloat(at)) + outlet_float((t_outlet *)o,GetFloat(at)); +#if FLEXT_SYS == FLEXT_SYS_MAX + else if(IsInt(at)) + outlet_flint((t_outlet *)o,GetInt(at)); +#endif +#if FLEXT_SYS == FLEXT_SYS_PD + else if(IsPointer(at)) + outlet_pointer((t_outlet *)o,GetPointer(at)); +#endif + else + error("Atom type not supported"); + CRITOFF(); + } +} + #elif FLEXT_SYS == FLEXT_SYS_JMAX void flext_base::ToSysBang(int n) const { fts_outlet_bang((fts_object *)thisHdr(),n); } @@ -52,6 +75,7 @@ void flext_base::ToOutBang(int n) const { if(CHKTHR()) ToSysBang(n); else ToQueu void flext_base::ToOutFloat(int n,float f) const { if(CHKTHR()) ToSysFloat(n,f); else ToQueueFloat(n,f); } void flext_base::ToOutInt(int n,int f) const { if(CHKTHR()) ToSysInt(n,f); else ToQueueInt(n,f); } void flext_base::ToOutSymbol(int n,const t_symbol *s) const { if(CHKTHR()) ToSysSymbol(n,s); else ToQueueSymbol(n,s); } +void flext_base::ToOutAtom(int n,const t_atom &at) const { if(CHKTHR()) ToSysAtom(n,at); else ToQueueAtom(n,at); } void flext_base::ToOutList(int n,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysList(n,argc,argv); else ToQueueList(n,argc,argv); } void flext_base::ToOutAnything(int n,const t_symbol *s,int argc,const t_atom *argv) const { if(CHKTHR()) ToSysAnything(n,s,argc,argv); else ToQueueAnything(n,s,argc,argv); } diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 41b201d7..9277887b 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -32,7 +32,11 @@ flext::thrid_t flext::thrmsgid = 0; class qmsg { public: - void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) { th = t,out = o,sym = s,argc = ac,argv = av; } + void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) + { + th = t; out = o; + sym = s,argc = ac,argv = av; + } // \note PD sys lock must already be held by caller void Send() const @@ -98,10 +102,11 @@ public: { t_atom *at = GetAtoms(1); SetInt(*at,dt); + const t_symbol *sym; #if FLEXT_SYS == FLEXT_SYS_PD - const t_symbol *sym = sym_float; + sym = sym_float; #elif FLEXT_SYS == FLEXT_SYS_MAX - const t_symbol *sym = sym_int; + sym = sym_int; #else #error Not implemented! #endif @@ -115,6 +120,30 @@ public: Set(th,o,sym_symbol,1,at); } + void Push(flext_base *th,int o,const t_atom &a) + { + t_atom *at = GetAtoms(1); + *at = a; + const t_symbol *sym; + if(IsSymbol(a)) + sym = sym_symbol; + else if(IsFloat(a)) + sym = sym_float; +#if FLEXT_SYS == FLEXT_SYS_MAX + else if(IsInt(a)) + sym = sym_int; +#endif +#if FLEXT_SYS == FLEXT_SYS_PD + else if(IsPointer(a)) + sym = sym_pointer; +#endif + else { + error("atom type not supported"); + return; + } + Set(th,o,sym,1,at); + } + void Push(flext_base *th,int o,int argc,const t_atom *argv) { t_atom *at = GetAtoms(argc); @@ -312,6 +341,12 @@ void flext_base::ToQueueSymbol(int o,const t_symbol *s) const Trigger(); } +void flext_base::ToQueueAtom(int o,const t_atom &at) const +{ + queue.Push(const_cast(this),o,at); + Trigger(); +} + void flext_base::ToQueueList(int o,int argc,const t_atom *argv) const { queue.Push(const_cast(this),o,argc,argv); diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h index 0bc70cd3..0a63111e 100644 --- a/externals/grill/flext/source/flstdc.h +++ b/externals/grill/flext/source/flstdc.h @@ -118,6 +118,7 @@ extern "C" { #include "ext.h" #include "ext_user.h" +#include "ext_critical.h" #include "z_dsp.h" } // extern "C" diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index be64b1e2..31b64f2a 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -437,11 +437,11 @@ public: //! Check whether the atom can be a pointer static bool CanbePointer(const t_atom &a) { return IsPointer(a); } //! Access the pointer value (without type check) - static void *GetPointer(const t_atom &a) { return a.a_w.w_gpointer; } + static t_gpointer *GetPointer(const t_atom &a) { return a.a_w.w_gpointer; } //! Check for a pointer and get its value - static void *GetAPointer(const t_atom &a,void *def = NULL) { return IsPointer(a)?GetPointer(a):def; } + static t_gpointer *GetAPointer(const t_atom &a,t_gpointer *def = NULL) { return IsPointer(a)?GetPointer(a):def; } //! Set the atom to represent a pointer - static void SetPointer(t_atom &a,void *p) { a.a_type = A_POINTER; a.a_w.w_gpointer = (t_gpointer *)p; } + static void SetPointer(t_atom &a,t_gpointer *p) { a.a_type = A_POINTER; a.a_w.w_gpointer = (t_gpointer *)p; } #elif FLEXT_SYS == FLEXT_SYS_MAX //! Check for a float and get its value @@ -645,6 +645,29 @@ public: // --- thread stuff ----------------------------------------------- + /*! \defgroup FLEXT_S_LOCK Global system locking + @{ + */ + +#if FLEXT_SYS == FLEXT_SYS_PD + #if PD_MINOR_VERSION >= 38 || (PD_MINOR_VERSION >= 37 && defined(PD_DEVEL_VERSION)) + static void Lock() { sys_lock(); } + static void Unlock() { sys_unlock(); } + #else + // no system locking for old PD versions + static void Lock() {} + static void Unlock() {} + #endif +#elif FLEXT_SYS == FLEXT_SYS_MAX + // Max 4.2 upwards! + static void Lock() { critical_enter(0); } + static void Unlock() { critical_exit(0); } +#else +#error +#endif + +//! @} FLEXT_S_LOCK + #ifdef FLEXT_THREADS /*! \defgroup FLEXT_S_THREAD Flext thread handling @{ -- cgit v1.2.1