If I call playSound("2secondWavFile.wav") from one chart and another chart calls a playSound at the same time, it appears as though the 2nd playSound doesn't play (at least I can't hear it). To address this problem I'm trying to constuct some type of crude thread syncronization lock using a global variable and a while loop such that if one wav file is playing, any other calls to playSound will block till the first wav file completes and I will hear both wav files completely. I'm thinking something like the following should work:
//globals
var vThreadLock=0;
main()
{
.
.
.
vThreadLock = getGlobalValue( "threadLock" );
while (vThreadLock != 0)
{
printDebugln("waiting");
}
setGlobalValue("threadLock", 1);
playSound("myAlert.wav");
setGlobalValue("threadLock", 0);
}
Is this a good/safe way to aproach this problem? Are there any potential thread syncronization problems such as a potential race condition or deadlock? Do all the EFS scripts run on a single thread? If so, I would assume there would be no threading issues however I would also assume if two different scripts called playSound at the same time, the 2nd playSound would block till the first playSound completed unless perhaps the playSound function runs on its own thread.
Any help along these lines would be apreciated.
//globals
var vThreadLock=0;
main()
{
.
.
.
vThreadLock = getGlobalValue( "threadLock" );
while (vThreadLock != 0)
{
printDebugln("waiting");
}
setGlobalValue("threadLock", 1);
playSound("myAlert.wav");
setGlobalValue("threadLock", 0);
}
Is this a good/safe way to aproach this problem? Are there any potential thread syncronization problems such as a potential race condition or deadlock? Do all the EFS scripts run on a single thread? If so, I would assume there would be no threading issues however I would also assume if two different scripts called playSound at the same time, the 2nd playSound would block till the first playSound completed unless perhaps the playSound function runs on its own thread.
Any help along these lines would be apreciated.
Comment