-10863 error - Help!
-10863 error - Help!
- Subject: -10863 error - Help!
- From: Steve Gehrman <email@hidden>
- Date: Mon, 14 Jun 2004 00:13:59 -0700
I'm trying to use the core audio sample code to save an audio stream to
a file. It works great if the source format is the same as the file
format, but I get an --10863 error from AudioUnitRender in the
CAAudioFileRecorder::InputProc if the formats are different.
I modified the sample to call SetClientFormat() to set the input
format, but it still fails.
Please help!!
Here's my code that sets up the CAAudioFileRecorder.
- (void)startRecordFromDevice:(MTCoreAudioDevice*)inputDevice;
{
const int kNumberBuffers = 3;
const unsigned kBufferSize = 0x8000;
_recorder = (void*) new CAAudioFileRecorder(kNumberBuffers,
kBufferSize, [inputDevice deviceID]);
CAStreamBasicDescription fileFormat;
fileFormat.mSampleRate = 44100.; // later get this from the hardware
fileFormat.mFormatID = kAudioFormatLinearPCM;
fileFormat.mFormatFlags = kAudioFormatFlagIsBigEndian |
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
fileFormat.mFramesPerPacket = 1;
fileFormat.mChannelsPerFrame = 2;
fileFormat.mBitsPerChannel = 16;
fileFormat.mBytesPerPacket = fileFormat.mBytesPerFrame = 4;
_file = (void*) new CAAudioFile;
((CAAudioFile *) _file)->PrepareNew(fileFormat, 44100.);
MTCoreAudioStream* stream = [inputDevice
streamForDirection:kMTCoreAudioDeviceRecordDirection];
MTCoreAudioStreamDescription *desc = [stream
streamDescriptionForSide:kMTCoreAudioStreamLogicalSide];
CAStreamBasicDescription deviceFormat([desc
audioStreamBasicDescription]);
((CAAudioFile *) _file)->SetClientFormat(deviceFormat);
((CAAudioFile *) _file)->Create([_destPath UTF8String],
kAudioFileAIFFType);
((CAAudioFileRecorder*)_recorder)->SetFile(((CAAudioFile *)
_file)->GetAudioFileID());
((CAAudioFileRecorder*)_recorder)->Start();
}
OSStatus CAAudioFileRecorder::InputProc(
void * inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp * inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList * ioData)
{
CAAudioFileRecorder *This = static_cast<CAAudioFileRecorder
*>(inRefCon);
AudioUnitRenderActionFlags flags = 0;
AudioBufferList *abl =
&This->mAudioInputPtrs->GetModifiableBufferList();
OSStatus err = AudioUnitRender(This->mInputUnit, &flags, inTimeStamp,
1, inNumberFrames, abl);
if (err)
{
printf("err: %d", err);
return err;
}
This->PushBuffer(inNumberFrames, abl);
return noErr;
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.