AudioConverterFillComplexBuffer, '!pkd' error
AudioConverterFillComplexBuffer, '!pkd' error
- Subject: AudioConverterFillComplexBuffer, '!pkd' error
- From: dct <email@hidden>
- Date: Sun, 05 Jul 2009 17:09:04 -0700
I am experiencing a problem with AudioConverterFillComplexBuffer
returning an error: '!pkd'. The only discussion of this error that I
can find is a 2007 thread titled: "AAC and AudioConverter error 'pkd'
error".
In that case the problem was handled by sending an error from the
input proc when no more input data were available. In my case, the
input proc is called only once and input data are provided.
In the Converter call to input proc, the item,
"outDataPacketDescription" is a valid pointer but
*outDataPacketDescription = 0x0 (i.e., nada). Does this mean that I
need to pass a pointer to an AudioStreamPacketDescription instance
back to the Converter? Or is this normal behavior? I would've
thought that the Converter generated it's own outDataPacketDescription
from the output ASBD provided in the preceding AudioConverterNew() call.
I am running OS X 10.5.7 / Xcode 3.3.3 and trying to make
AudioConverterFillComplexBuffer work using AudioFileStream.
My process goes as follows:
1. Establish an AudioConverter instance, aCnvrtr:
err = AudioConverterNew(&dcdrDotH->asbdIn,
&dcdrDotH->asbdOut, &aCnvrtr);
The AudioStreamBasicDescription, asbdIn (as provided by a
PropertyListener callback), is as follows:
mSampleRate 44100
mFormatID 778924083 ('.mp3' )
mFormatFlags 0
mBytesPerPacket 0
mFramesPerPacket 1152
mBytesPerFrame 0
mChannelsPerFrame 2
mBitsPerChannel 0
The AudioStreamBasicDescription, asbdOut (set internally), is as
follows:
mSampleRate 44100
mFormatID 1819304813 ('lpcm' )
mFormatFlags 9 ( kAudioFormatFlagIsFloat |
kAudioFormatFlagIsPacked )
mBytesPerPacket 8
mFramesPerPacket 1
mBytesPerFrame 8
mChannelsPerFrame 2
mBitsPerChannel 32
2. Create an AudioBufferList, aBufList, to accommodate a block (~1sec)
of converted output.
aBufList.mNumberBuffers = 1;
aBufList.mBuffers[0].mNumberChannels = 1;
aBufList.mBuffers[0].mData = outBufferPtr; // (already allocated)
nPckts = 44100/1152; // (i.e., mSampleRate/mFramesPerPacket)
reqFrms = nPckts * 1152;
bufferSz = reqFrms * asbdOut.mBytesPerFrame;
aBufList.mBuffers[0].mDataByteSize = bufferSz;
3. Prepare data (inProcData) for supply to
AudioConverterFillComplexBuffer().
inProcData.inPcktDescPtr = aspdIn;
/* ( aspdIn is the AudioStreamPacketDescription pointer to the
ASPD
included in the Parser call to its PacketProc callback) */
inProcData.inputData = inBufferPtr; // (externally provided)
inProcData.ioBufferSize = bufferSz;
inProcData.ioBuffer = malloc( bufferSz );
inProcData.ioBufferList.mNumberBuffers = 1;
inProcData.ioBufferList.mBuffers[0].mNumberChannels = 1;
inProcData.ioBufferList.mBuffers[0].mDataByteSize = bufferSz;
inProcData.ioBufferList.mBuffers[0].mData = inProcData.ioBuffer;
inProcData.packetOffset = 0;
inProcData.bytesCounter = 0;
4. Call AudioConverterFillComplexBuffer
err = AudioConverterFillComplexBuffer( aCnvrtr, inputCallback,
&inProcData, &reqFrms, &aBufList, NULL );
/* This returns the error = '!pkd'.
aBufList.mBuffers[0].mData remains unchanged (was set all 1s
to check).
inProcData.ioBuffer seems to be input data--as set in
inputCallback. */
4.a Callback function "inputCallback". (called once, as expected)
{
...
InputProcessData *callBack=(InputProcessData *)inUserData;
AudioStreamPacketDescription *inASPD = callBack->inPcktDescPtr;
void *in=callBack->inputData;
...
*ioData = callBack->ioBufferList;
frstPckt = callBack->packetOffset;
nxt1stPckt = frstPckt + callBack->stdInPcktCount;
*ioNumberDataPackets = nxt1stPckt - frstPckt; // these are
input pckt nmbrs
inByte0 = inASPD[frstPckt].mStartOffset;
bytes = inASPD[nxt1stPckt-1].mStartOffset - inByte0
+ inASPD[nxt1stPckt-1].mDataByteSize;
in += inByte0;
memcpy((char *)ioData->mBuffers[0].mData, (const char *)in, bytes);
callBack->packetOffset = nxt1stPckt;
callBack->bytesCounter += bytes;
}
Thanks for the help, Don Thompson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden