I've been having a very brief look at the audio example/drivers supplied with the latest PSP. I've not got much further than reading the source for the Audio wrapper around the CODEC and McASP drivers (found at ...\pspdrivers_01_20_00_07\packages\ti\pspiom\platforms\evmOMAPL137\audio\src\Audio.c).
My question is: Is this driver considered production worthy?
Here is a quick list of a few things that jumped out at me when glancing over the source:
- audioMdCreateChan()
When creating a channel there is a check to see if the driver is closed (i.e. has not been opened), and if so it is opened and extra initialisation is performed. It appears the author attempted to make this check thread-safe, however only the "set" of the "test-and-set" operation is atomic. The "_disable_interrupts();" (line 339) should be before the check "if (Audio_DriverState_CLOSED == chanHandle->chanState)" (line 335), otherwise there is a race condition in which this thread may be descheduled after the check but before claiming the resource.
- audioMdDeleteChan()
There are multiple invocations of the call-backs to delete the channel for the McASP and any number of CODECs, however all the return codes apart from the last CODEC are silently ignored before being checked (line 679, 686). This is worrying as if the last CODEC deletes the channel fine but the McASP and all other CODECs fail no notification is given to the caller.
I've stopped reading through the source for the time being, as if it's not production worthy i'll wait for some that is. I'll admit these are minor corner cases - but often cases like these are the ones that turn out to be a real pain to debug later on!
I assume TI has acceptance/release procedures, is there any documentation detailing these? When are drivers considered production ready?
Thanks!