audiality2 icon indicating copy to clipboard operation
audiality2 copied to clipboard

xinsert API unreliable with realtime states

Open olofson opened this issue 7 years ago • 3 comments

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 avatar May 11 '17 22:05 olofson

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 avatar May 14 '17 09:05 olofson

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 avatar May 14 '17 10:05 olofson

See also #337.

olofson avatar Dec 07 '17 11:12 olofson