Sync threading details

Started by podobo,

podobo

I've got some external library calls I'm calling in a sync function, specifically in a BASS_SYNC_MUSICINST callback, and I'm experiencing crashes.

Now, I don't think this is the fault of BASS, but rather that the code I'm calling isn't friendly in a threaded environment, or has certain requirements in a threaded environment that I'm trying to figure out.

One thing I noticed is that when the sync uses BASS_SYNC_MIXTIME, the code I'm calling crashes on the third time the callback is called.  If I don't use BASS_SYNC_MIXTIME, it crashes the second time it is called.  So far these numbers seem reproducible and exact.

That may not have anything specifically to do with my problem.. but I was just wondering if there are any specific threading issues to keep in mind within BASS callbacks.


Ian @ un4seen

You can do pretty much whatever you want within a sync callback. There are some restrictions when using a "mixtime" sync though, which are mentioned in the SYNCPROC docs.

podobo

Are callbacks ever called asynchronously?

Ian @ un4seen

It is possible for a "normal" sync and a "mixtime" sync function to be called simultaneously, because they run in different threads (mixtime syncs run in the mixing thread). But it's not possible for more than one of each to be called at a time, unless what you do in a mixtime sync function triggers another mixtime sync. And, if that triggers another one (etc...), you could end up with a stack fault, as in this thread:
    http://un4seen.com/YaBB.cgi?board=bass&action=display&num=1046517629