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.

Sunday, May 01, 2005

What Does the Spec Say?

If I want to get S/P DIF bypass mode, I should first try to do it in a non-hackish, standard compliant way. So, what does USB.ORG have to say about the matter? Well, it does provide some info in the form of version 1.0 of the Universal Serial Bus Device Class Definition for Audio Devices, and more importantly the supplementary Universal Serial Bus Device Class Definition for Audio Data Formats.

What do I learn from this? Well, I find out that what I want is the device to support a Type Ⅲ format. A Type Ⅰ format would be normal PCM. A Type Ⅱ format would be the case where my receiver had a USB connector and took in AC-3 or MP3 files directly. In a Type Ⅲ format, the compressed format is sent along as pseudo-PCM which is what I need. Unfortunately, the specification says that if my device supports such a thing, it should have an alternate streaming interface exactly the same as the PCM interface, except the format type should be FORMAT_TYPE_III, and of course my AAM device has no such interface.

The other potentially useful bit of information that a Type Ⅲ stream “The non-PCM encoded audio bitstreams that are transferred within the basic 16-bit data area of the IEC1937 subframes (time-slots 12 [LSB] to 27 [MSB]) are placed unaltered in the two available 16-bit audio subframes per audio frame of the Type Ⅲ formatted USB stream. The additional information in the IEC1937 subframes (channel status, user bits etc.) is discarded. Refer to the IEC1937 standard for a detailed description of the exact contents of the subframes.” Well that is interesting, and if true, how is the receiver supposed to figure out that it's seeing a compressed stream? Or will a supporting USB device add this information back in for you?

Oh, I watched the director's cut of Daredevil on my PC using the AAM, and I got beautiful DTS 5.1. Given the importance of sound in that film, surround sound is the way to go. Also, the director's cut is the way to go; the story has much better flow, and makes more sense.