Re:Four common mistakes in audio development (2016)
by Gibbon1 on Sunday September 22, 2019 @07:00PM
(#21044536)
The problem with locks on a non real time os is that the OS may decide to interrupt your thread while it's holding the lock. No matter how short that is. I do embedded I've had similar things happen when the 'lock' is held for just a few instructions.
Tip: If you suspect crap like this, adding spin delays will make it happen often enough to debug.
Re:Four common mistakes in audio development (2016)
by proverbialbunny on Sunday September 22, 2019 @11:18PM
(#21045674)
By any chance do you have any references or information on how to do this (adding a spin delay)? It sounds interesting. -thanks :)
Re:Four common mistakes in audio development (2016)
by Gibbon1 on Sunday September 22, 2019 @11:37PM
(#21045742)
In C it's very simple
volatile int cnt = 0x1000;
while(cnt--)
;
Re:Four common mistakes in audio development (2016)
by hoseja on Monday September 23, 2019 @04:06AM
(#21046861)
I've grown so paranoid of optimizing compilers this wouldn't even cross my mind. But it is correct, right?
Re:Four common mistakes in audio development (2016)
by AlbertoGP on Monday September 23, 2019 @04:55AM
(#21047109)
Not OP, but the “volatile” qualifier should prevent the compiler from optimizing it out.
Re:Four common mistakes in audio development (2016)
by Gibbon1 on Monday September 23, 2019 @05:31PM
(#21053945)
Yeah should.
Multicore super scalar processors make me nervous about my assumptions. I wouldn't put it past one of them to realize that the result is unused and nop it.
It's always good to check.
Re:Four common mistakes in audio development (2016)
by vemv on Monday September 23, 2019 @02:21AM
(#21046396)
I see now, thanks!
Re:Four common mistakes in audio development (2016)
by suraj on Sunday September 22, 2019 @11:42PM
(#21045759)
It is possible to use Swift on audio thread. You have to be careful not to use any reference counted (i.e. class) objects. If you do need to perform allocations (e.g. creating CMSampleBuffer instances), use a custom allocator.
Re:Four common mistakes in audio development (2016)
by lfnoise on Tuesday September 24, 2019 @03:48PM
(#21063860)
I had someone on the Swift compiler team tell me unequivocally that they make no real time guarantees. Unless you can point to somewhere in the language documentation that the runtime is guaranteed not to ever do X, then I would not assume that you could. (me: former Apple CoreAudio engineer)
Re:Four common mistakes in audio development (2016)
by iainmerrick on Sunday September 22, 2019 @06:20PM
(#21044355)
If there’s no contention, why do you think they’re there?
Re:Four common mistakes in audio development (2016)
by vemv on Monday September 23, 2019 @12:55AM
(#21046010)
They could be there as a guardrail for a worst-case scenario, without them being particularly needed for the average use case.
Re:Four common mistakes in audio development (2016)
by jstsch on Sunday September 22, 2019 @04:31PM
(#21043738)
You can use Objective C on the audio thread just fine in practice. Just don’t call out.
Re:Four common mistakes in audio development (2016)
by adamnemecek on Sunday September 22, 2019 @05:36PM
(#21044112)
No, you really can't. Show me a single audio app that uses objc in the render block.
His argumentation is that Objective-C uses locks internally.
But isn't it possible that those locks (as opposed to application-level locks) cause just negligible pauses, because there's no contention on them?
I guess those internal locks exist to make ObjC's runtime dynamism feasible. One would expect the typical application to not leverage that dynamism (how many apps continously redefine methods under normal operation?).