Re: Endless loop running AudioConverterFillComplexBuffer
Re: Endless loop running AudioConverterFillComplexBuffer
- Subject: Re: Endless loop running AudioConverterFillComplexBuffer
- From: james mccartney <email@hidden>
- Date: Mon, 13 Jul 2009 10:11:47 -0700
I can't really tell from this. You're sure you aren't returning a
packet description of zero bytes? That is my only guess at this point.
On Jul 11, 2009, at 12:39 PM, dct wrote:
Thanks to James McCartney, my '!pkd' problem is corrected.
Now, having taken care of that, I have a situation where
AudioConverterFillComplexBuffer calls the inputProc once and then
goes into an infinite loop.
My code is below. Values shown are for a case to convert one input
packet of an mp3 input to pcm.
a. The converter call --
err = AudioConverterFillComplexBuffer( aCnvrtr, inputCallback,
&inProcData, &nxtDataSz,
&aBufList, NULL );
// nxtDataSz = 9216 (output bytes from 1 input packet)
b. The inputProc ( titled "inputCallback ") --
OSStatus inputCallback(
AudioConverterRef inAudioConverter,
UInt32 *ioNumberDataPackets,
AudioBufferList *ioData,
AudioStreamPacketDescription
**outDataPacketDescription,
void *inUserData )
{
InputProcessData *callBack = (InputProcessData *)inUserData;
AudioStreamPacketDescription *inASPD = callBack->inPcktDescPtr;
AudioBufferList *bufferList = callBack->ioBufferList;
void *in = callBack->inputData;
UInt32 frstPckt, nxt1stPckt, inByte0, inBytes, nn;
if( !inUserData || !*ioNumberDataPackets ) return( -1 );
frstPckt = callBack->packetOffset;
nxt1stPckt = frstPckt + callBack->stdInPcktCount;
if( nxt1stPckt >= callBack->todoPacketCount ) {
nxt1stPckt = callBack->todoPacketCount;
}
*ioNumberDataPackets = nn = nxt1stPckt - frstPckt;
// =1, (ok, one input packet)
inByte0 = inASPD[frstPckt].mStartOffset; // = 0, (ok)
inBytes = inASPD[nxt1stPckt-1].mStartOffset - inByte0 +
inASPD[nxt1stPckt-1].mDataByteSize;
// = 627 (ok, input pckt size)
in += inByte0; // =0x162aa09d (ok = inputData)
ioData->mNumberBuffers = 1;
ioData->mBuffers[0].mNumberChannels = 1;
ioData->mBuffers[0].mDataByteSize = inBytes; // = 627
ioData->mBuffers[0].mData = bufferList->mBuffers[0].mData;
// = 0x8ac800 ( ok = ioBuffer)
memcpy((char *)ioData->mBuffers[0].mData, (const char *)in, inBytes);
*outDataPacketDescription = callBack->outPcktDescPtr;
callBack->outPcktDescPtr->mStartOffset = 0;
callBack->outPcktDescPtr->mVariableFramesInPacket = 1;
// doesn't work w 0 either
callBack->outPcktDescPtr->mDataByteSize =
nn * callBack->outBytsPerInPckt;
// = 9216 (ok 1152 frms*8 bytes/frm)
callBack->packetOffset = nxt1stPckt;
callBack->bytesCounter += inBytes;
return noErr;
}
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