AudioUnit « Tonny Xu
...Life is like a box of chocolates,
you never know what you’re gonna get...
» AudioUnit «

Today I met a weird exception from AUGraphStart().

Basically, I was running an old sample code written by myself. The main function is mix 2 audio files a playback them simultaneously. I worked fine before, but when I run it, I got this exception:

[00:23:58.425 <AURemoteIOServer>] AQMEIOBase::DoStartIO: timeout
[00:23:58.701 <AURemoteIOServer>] AQMEDevice::StartIO: AudioOutputUnitStart returned -66681
[00:23:58.701 <0xa084a720>] AUIOClient_StartIO failed (-66681)
AUGraphStart FFFEFB87 

Obviously, it wasn’t came from my code, and I have no idea on this exception now. Did anybody get a same exception recently?

I had tried these:

   1. Restart the XCode. — No effects.

   2. Restart the machine(Mac Pro, 10.5.7), and restart the XCode. — No effects.

   3. Reinstall the most recent SDK(Build 9M2735), restart the XCode. — No effects.

   4. Set the base SDK to 2.2.1 and target to Simulator 2.2.1 Debug. — No effects.

It’s really odd!

Please, if anybody had met similar exception and got a solution, help me out!

Still don’t know how to resolve it now. I need  help!

[Update 2009-06-11]

A week ago, Apple’s engineer had confirmed that they had a bug in UIKit framework.

We do have a simple workaround for this UIKit bug. In UILocalizedIndexedCollation.hm change this:

  UIKIT_EXTERN @interface UILocalizedIndexedCollation : NSObject

to

  UIKIT_EXTERN_CLASS @interface UILocalizedIndexedCollation : NSObject

Having done that, we can build your project and confirm that AUGraphStart returns 0 in the 3.0 simulator.

 

But, after I installed the 3.0 GM Version today, it’s still not included in the GM Version. So that means I still can not play audio in the simulator. I can ONLY do it on the device!

Comments

Apple release iPhone SDK based on Mac OS 10.5, and they used a lot of concept which is used in Mac OS directly in iPhone development. But to tell the truth, even the Mac development documentation is still lack of a lot of details, so Apple just leave those jungles directly to iPhone developers. Today, let talk about AudioUnit and the parameters.

AudioUnit is a good library, it provides a lot of predefined processes for us to deal with the audio data. But I have to say, Apple, you really leave a huge jungle in AudioUnit. You can almost find no useful documents for you to understand the APIs. If you want to use an AudioUnit, you do need to invoke a lot of function in a certain sequence. Otherwise, the AudioUnit will refuse to work.

After you properly set up the AudioUnits and AUGraph, you still might be confused when you want to just some properties of a AudioUnit on the fly, you will find out that you are falling into another jungle. You will hard to know which parameter to use and how to use it. Because All you can access the parameters of an AudioUnit is AudioUnitSetParameter. If you look into this API’s document, you will see what the real jungle is:

AudioUnitSetParameter
Sets the value of an audio unit parameter.


OSStatus AudioUnitSetParameter (
AudioUnit inUnit,
AudioUnitParameterID inID,
AudioUnitScope inScope,
AudioUnitElement inElement,
AudioUnitParameterValue inValue,
UInt32 inBufferOffsetInFrames
);


Parameters
inUnit
The audio unit that you want to set a parameter value for.


inID
The audio unit parameter identifier.


inScope
The audio unit scope for the parameter.


inElement
The audio unit element for the parameter.


inValue
The value that you want to apply to the parameter.


inBufferOffsetInFrames
Set this to 0. To schedule the setting of a parameter value, use the AudioUnitScheduleParameters function.


Return Value
A result code.


Availability
Available in iPhone OS 2.0 and later.
See Also
AudioUnitGetParameter
AudioUnitScheduleParameters
Declared In
AUComponent.h

See, the first parameter is easy to understand, it means which AudioUnit you want to set/change a parameter with.
the second one will be a little confused, because you need to find out each AudioUnit has which kind of parameters at all. Well, to tell the truth, if you don’t know a parameter name, there is no way for you to jump to the parameters defination! So, here is what might be help to you. [Click Here(Local help URL, if you don't have iPhone SDK documentations installed in your system, don't click this URL)]. And don’t forget to bookmark it! ;-p

Comments