From: Florian J. <fl...@wi...> - 2014-01-27 05:55:02
|
Am 27.01.2014 02:02, schrieb Dennis Schulmeister: > Hi Florian, > > That sounds like a very reasonable approach. Though I'd try to avoid > mutex locks between GUI and prefetch thread, if possible. For me the > prefetch thread is not as time critical as "audio" but it has hard > deadlines, too in order to avoid buffer underruns. > > So here is a slightly modified idea in pseudo-code as it's too late for > me to describe it in words. :-) [you meant having one model in usage and one copy for editing, and swapping their pointers after editing since swapping is a 'fast' operation] Thanks for your feedback :)! Hm, yeah, that would be an option. Though duplicating the whole model is a bit much, I think. Note that we would need to copy all sorts of audio structures as well, which can be quite some amount of data. I've thought about (and ardour does it :)) using a Diff system: When the GUI wants to edit stuff, it creates a Diff (which is not applied yet), which is ready to apply, with everything prepared. At the end: mutex.lock(); mydiff.apply(); // should work reasonably fast mutex.unlock(); Since the audio prefetch prefetches at least 0.5 seconds (doesn't it?), and human UI latency perception is definitely too high at 0.5 seconds, I guess that we will be fine with this: Because the operating system will give the GUI thread enough CPU time to complete and unlock the mutex within, say, 0.4 seconds, which is enough to not buffer-underrun. Cheers, Florian |