Tuesday, May 31, 2005

Darwin Station

Well as luck would have it, Apple has open sourced much of their core operating system, including the driver for USB audio, as part of their Darwin project. So I downloaded the AppleUSBAudio-199.2.10 archive.

Getting it to compile was a bit of a chore, as they are transitioning towards using real 64 bit integers for things like time stamps, so I had to cast this and that, and change a few variable types. I haven't actually figured out how one installs a driver in place of its original.

But I did notice something strange, a probable bug that might lead to the driver not recognizing if a device could support an S/PDIF connection. In the AppleUSBAudioEngine::AddAvailableFormatsFromDevice method there is a for loop

for (altSettingIndx = 1; altSettingIndx < numAltInterfaces; altSettingIndx++) {

and then after the for loop, the altSettingIndx variable is used again to test for an S/PDIF interface, but I don't think it's a valid index and it looks like the test was supposed to be in the for loop.

I'll try to find someone at WWDC to confirm this is a bug.