Csound Csound-dev Csound-tekno Search About

csoundCreateThread in Swift 3

Date2016-11-01 17:28
FromCasey Mongoven
SubjectcsoundCreateThread in Swift 3
Hi Csounders!

Has anyone run into issues or been successful calling csoundCreateThread
from Swift 3? All the other functions I am using work but when I run this
line of code:

csoundCreateThread(performance_function, UnsafeMutableRawPointer(csound))

I get this error:

Cannot convert value of type '(UnsafeMutableRawPointer!) -> UInt' to
expected argument type '(@convention(c) (UnsafeMutableRawPointer?) ->
UInt)!'

The performance function seems to be causing an issue. It looks like the
standard c function:

uintptr_t performance_function(void* data) {
    CSOUND* csound = (CSOUND*) data;
    while (csoundPerformKsmps(csound) == 0) {}
    return 0;
}

This line of code was working in Swift 1.0 and now it seems to be broken.
Any ideas as to what needs to be changed or added? Thank you guys.



--
View this message in context: http://csound.1045644.n5.nabble.com/csoundCreateThread-in-Swift-3-tp5752387.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-11-01 21:54
FromCasey Mongoven
SubjectRe: csoundCreateThread in Swift 3
What I ended up doing was just creating a work-around, using a void function
to call csoundCreateThread from a .c instead of a .swift file:

void register_performance_function(void* data) {
    CSOUND* csound = (CSOUND*) data;
    csoundCreateThread(performance_function, csound);
}




--
View this message in context: http://csound.1045644.n5.nabble.com/csoundCreateThread-in-Swift-3-tp5752387p5752395.html
Sent from the Csound - General mailing list archive at Nabble.com.

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here