Note that there are some explanatory texts on larger screens.

plurals
  1. POAudioUnit set property error (error code -10868)
    text
    copied!<p>I am trying to set a property in AudioUnit using AudioStreamBasicDescription. I am trying to set the format for the sound data. The error code returned is -10868. It only occurs on iOS 3.1.3 or less, but works on 3.2 or up. So it works in the simulator, on an iPod touch running 4.2, but not a 1st gen iPod touch.</p> <p>The error occurs when I try to set the format for the AudioUnit tone unit. The code looks like this (and is from <a href="http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html" rel="nofollow">cocoawithlove.com</a>)</p> <pre><code>// Set the format to 32 bit, single channel, floating point, linear PCM const int four_bytes_per_float = 4; const int eight_bits_per_byte = 8; AudioStreamBasicDescription streamFormat; streamFormat.mSampleRate = sampleRate; streamFormat.mFormatID = kAudioFormatLinearPCM; streamFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved; streamFormat.mBytesPerPacket = four_bytes_per_float; streamFormat.mFramesPerPacket = 1; streamFormat.mBytesPerFrame = four_bytes_per_float; streamFormat.mChannelsPerFrame = 1; streamFormat.mBitsPerChannel = four_bytes_per_float * eight_bits_per_byte; err = AudioUnitSetProperty (toneUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &amp;streamFormat, sizeof(AudioStreamBasicDescription)); // err now has error code -10868 </code></pre> <p>I checked around in headers and this error code corresponds to the error "kAudioUnitErr_FormatNotSupported". So I guess the format I'm trying to set is not supported on iOS 3.1? Where can I find supported formats? Any pointers on other formats I could try out?</p> <p>The render callback used:</p> <pre><code>OSStatus RenderTone( void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { // Fixed amplitude is good enough for our purposes const double amplitude = 0.25; // Get the tone parameters out of the view controller ToneGeneratorViewController *viewController = (ToneGeneratorViewController *)inRefCon; double theta = viewController-&gt;theta; double theta_increment = 2.0 * M_PI * viewController-&gt;frequency / viewController-&gt;sampleRate; // This is a mono tone generator so we only need the first buffer const int channel = 0; Float32 *buffer = (Float32 *)ioData-&gt;mBuffers[channel].mData; // Generate the samples for (UInt32 frame = 0; frame &lt; inNumberFrames; frame++) { buffer[frame] = sin(theta) * amplitude; theta += theta_increment; if (theta &gt; 2.0 * M_PI) { theta -= 2.0 * M_PI; } } // Store the updated theta back in the view controller viewController-&gt;theta = theta; return noErr; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload