Multithreaded external (Win32)?

Aug 4, 2012 at 1:40am

Multithreaded external (Win32)?

I have a Max external project which connects to a Wiimote and creates a secondary thread where I attempt to update the acceleration data and output the results to an outlet during each update frame. This seems to generate an access read violation at the following line:

outlet_anything(data->sender->m_outlet[1], gensym("accel"), 3, av);

I implemented a critical section in hopes that it would correct the issue, but it still fails. Does anyone have a working example of a multithreaded Max object? Is multithreading even allowed?

EDIT: Oops, I meant to post this in the Dev forum.

#63844
Aug 4, 2012 at 3:34am

I figured out what I was doing wrong. I should’ve been using the built-in Max threading and critical functions defined in ext_systhread.h and ext_critical.h, respectively. Before, I was using CreateThread() and EnterCriticalSection()/LeaveCriticalSection() as defined in the Windows headers.

#230257
Aug 4, 2012 at 5:38am

Hello,

i’m not used with win32 but afaik you can create thread as you want and use locks you need ; but main problem is to interract with Max API ; specially oultet calls. We currently have a topic about that : http://cycling74.com/forums/topic.php?id=41800

If the max threading API (wrapper for POSIX / win32) is an option for your project, use it for portability ; and you should have a look on the SDK’s simplethread.c example to manage outlet calls with “qelem” task.

HTH.

I moved your topic to dev.

#230258

You must be logged in to reply to this topic.