Chris Cannam - 2010-09-28

It's not quite that simple, I'm afraid -- there are threading issues to consider.

The JACK timebase callback is called from the JACK process thread, which is a real-time priority thread separate from the thread that the main GUI and engine runs in.

This means that (1) most of the methods on classes like Composition cannot safely be called from this thread because they do non-real-time-safe work such as memory allocations; and in any case (2) most of them cannot safely be called from any thread other than the main one without locking protection because they are not thread-safe.

Essentially we need to push the timing data to the process thread rather than pull it. Probably the GUI thread should push the series of time-tempo changes to the sequencer, with the mapping between real-time and musical time for each, and then the process thread should calculate based on the difference between its own real-time and that of the most recent time-tempo change. (The GUI cannot push "current time" to the process thread because it would always be somewhat ahead of real-time due to buffering.)