API question re multithreaded host.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

API question re multithreaded host.

Iain Duncan
A few questions on how to write a host that might be doing a lot of
other stuff at the same time as csound runs:

When I register a callback with csoundSetYieldCallback() and I am
performing csound with csoundPerformKsmps(), I gather the callback
function I register gets called when csound is done an audio pass and
there is left over cpu time.

Does this get called after an audio buffers worth or after a ksmp worth?
Does this get called even if there is no left over cpu time? Ie
absolutely every kpass?

What happens if the callback function does something long, can it starve
csound or does it get automatically pre-empted? Would it be possible to
simulate such a thing or implement that? Is it smart to spawn a new low
priority thread from the callback to do long things that should not
interfere with the csound thread? ( ie disk i/o )

What if the callback is short, but I want it to continue executing until
csound needs the cpu back? Ie getting messages off an input queue and
dealing with them. Does the callback get called repeatedly when csound
is done it's pass or just once? What would be the smart way of having
the callback continually process input messages until csound needs time
again? I could have a loop, but then it needs to give time back to
csound correct?

Also, if using csoundPerformKsmps() what would happen if I do a lot of
other stuff in that thread after the call, will I starve csound if
csound is running close to max, but be ok if there is cpu headroom?

Thanks
Iain


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/csound-devel
Reply | Threaded
Open this post in threaded view
|

Re: API question re multithreaded host.

Istvan Varga
Iain Duncan wrote:

> When I register a callback with csoundSetYieldCallback() and I am
> performing csound with csoundPerformKsmps(), I gather the callback
> function I register gets called when csound is done an audio pass and
> there is left over cpu time.
>
> Does this get called after an audio buffers worth or after a ksmp worth?
> Does this get called even if there is no left over cpu time? Ie
> absolutely every kpass?

It is undefined how frequently the yield callback is called, but it is
expected to be called often enough so that Csound can respond to user
input within a reasonable amount of time. Also, it has nothing to do
with CPU usage when the yield callback is called.
In general, this callback is used to update the GUI in a single threaded
environment (e.g. by calling Fl::wait), and to request termination of
Csound performance by returning zero.


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Csound-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/csound-devel