Under the Bridge

Tip: Porting Core Audio

Here is your tip of the day for porting Core Audio code from the desktop:

Look for the ::AudioUnitSetProperty() call which sets the HAL-feeding callback. If your desktop source is of Core Audio version 1 vintage, it will be using the constant


which still works perfectly in desktop code as of the Leopard SDK. Intriguingly, it will also compile perfectly fine with the iPhone 2.1 SDK — and produce no runtime error either. However, it will not work, leaving you utterly baffled as to just why on earth your perfectly good callback is never getting called back.

The solution is to change that constant to the newly correct


and then everything will play just fine.

A quick Google search shows me that the older constant is found, for instance, in lots of searchable archives of Simple DirectMedia Layer library code, SDL_coreaudio.c to be exact. So if you’re trying to port some libSDL-using project to the iPhone and wondering why your error-freely compiling and running code isn’t @#($&@!!! playing a @(#$^!!! thing … hey, check that out for starters!