csound / ctcsound

Python Bindings for Csound using ctypes. Can be used from python2.x and python3.x as well.
GNU Lesser General Public License v2.1
67 stars 10 forks source link

PerformanceThread #1

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi Francois!

I'm Eugene from the mailing list. How do you plan to proceed with running Csound in the separate thread? That's currently the main thing that concerns me. Maybe Mike's idea with creating a wrapper for C++ class was good, what do you think?

Best, Eugene

ghost commented 8 years ago

The PerfThread class does a great deal of synchronizing access to the Csound running in a thread. I looked on how to implement a callback functions in Python that could be passed to C code [1], but don't have the idea after skimming the docs.

  1. https://docs.python.org/3/library/ctypes.html#callback-functions
fggp commented 8 years ago

In the actual code there are two examples of setting callback functions: setFileOpenCallback (line 517) and setPlayOpenCallback (line 678). Corresponding member variables are set in the init method (lines 195, 196) to prevent callback references to be garbage collected.

I plan to write a pure python CsPerfThread class emulating the C++ class and whose methods will call corresponding pure C API functions (like do the original C++ class methods!). This would suppress one indirection level caused by a C wrapper of the C++ class.