olofson / audiality2

A realtime scripted modular audio engine for video games and musical applications.
http://audiality.org/
zlib License
79 stars 5 forks source link

xinsert API unreliable with realtime states #326

Open olofson opened 7 years ago

olofson commented 7 years ago

Calls like a2_OpenSink() and a2_OpenSource() sometimes fail, with the engine printing "Voice has no units (A2MT_ADDXIC)". Adding a substantial delay between spawning the target voice, and attaching to it, avoids the problem.

Notably, the streamstress and streamtest tests are broken, and will not work at all with some drivers. Low latency drivers, such as JACK, seem to work better, but there are still issues.

Apparently, the xinsert client setup messages arrive before the engine knows anything about the target voice. This is a solved problem (A2_TNEWVOICE; a handle that serves as a message queue until the actual voice has been created), and works for "everything" else. Did I forget something in the xinsert API when refactoring the API?

olofson commented 7 years ago

This probably explains it:

2064.000000:    h (0x11c1208) [ 0 ] START()
0.000000:   h (0x115e5b8) [ 1 ] Audiality 2: Incorrect timestamp for voice 0x115e5b8! (2048.000000 frames late.)
ADDXIC
olofson commented 7 years ago

a2_add_xic() is hardwired to the pre-A2_interface timestamping and messaging methods. Trivial fix.

The more hairy part is destroying XICs. We have the same problem in some other cases as well, I think. The problem is, handles and underlying objects don't keep track of which interface they "belong" to - and even if they did, we'd have to deal with interfaces being closed before these objects are destroyed.

olofson commented 6 years ago

See also #337.