diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index f17c5d59f6..ed6628123b 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -58,7 +58,7 @@ # define PBD_RT_PRI_MIDI pbd_pthread_priority (THREAD_MIDI) # define PBD_RT_PRI_PROC pbd_pthread_priority (THREAD_PROC) -LIBPBD_API int pthread_create_and_store (std::string name, pthread_t *thread, void * (*start_routine)(void *), void * arg); +LIBPBD_API int pthread_create_and_store (std::string name, pthread_t *thread, void * (*start_routine)(void *), void * arg, uint32_t stacklimit = 0x80000 /*512kB*/); LIBPBD_API void pthread_cancel_one (pthread_t thread); LIBPBD_API void pthread_cancel_all (); LIBPBD_API void pthread_kill_all (int signum); diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 33054a4222..af6af46065 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -117,14 +117,16 @@ fake_thread_start (void* arg) } int -pthread_create_and_store (string name, pthread_t* thread, void* (*start_routine) (void*), void* arg) +pthread_create_and_store (string name, pthread_t* thread, void* (*start_routine) (void*), void* arg, uint32_t stacklimit) { pthread_attr_t default_attr; int ret; /* set default stack size to sensible default for memlocking */ pthread_attr_init (&default_attr); - pthread_attr_setstacksize (&default_attr, 0x80000); // 512kB + if (stacklimit > 0) { + pthread_attr_setstacksize (&default_attr, stacklimit); + } ThreadStartWithName* ts = new ThreadStartWithName (start_routine, arg, name);