• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MP3 Packet Description Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MP3 Packet Description Problem


  • Subject: Re: MP3 Packet Description Problem
  • From: Mike Simmons <email@hidden>
  • Date: Fri, 29 Aug 2008 07:46:45 -0500

Thanks! I did have an actual instance of the AudioStreamPacketDescription struct, but I was neglecting to set the mVariableFramesInPacket to 1 in combination with passing a NULL in the argument list to AudioConverterFillComplexBuffer(). With those changes the program works like a charm.

Mike

On Aug 26, 2008, at 4:31 PM, Lukhnos D. Liu wrote:

On Aug 27, 2008, at 5:20 AM, Mike Simmons wrote:
A year or more ago I wrote an app that captures Shoutcast MP3 streams, decodes the audio into linear PCM using AudioConverterFillComplexBuffer(), and writes the audio to disk. It was working fine on Mac OS X 10.4. On 10.5, however, AudioConverterFillComplexBuffer() returns a "pkd!" error indicating that I need to include an AudioStreamPacketDescription argument in the AudioConverterFillComplexBuffer() call, rather than passing a NULL pointer as I had been doing successfully on 10.4.
I've modified my input proc to set the AudioStreamPacketDescription with an mDataByteSize of 417 (the size of the MP3 packets), an mStartOffset of 0, and an mVariableFramesInPacket set to 0. The input proc is called repeatedly the first time AudioConverterFillComplexBuffer() is invoked, and it eventually causes an EXC_BAD_ACCESS error.

Do you have a real instance of AudioStreamPacketDescription struct? I ran into similar problem just a while ago, then I solved this (I hope this is the correct solution) with this snippet:


OSStatus StudyComplexBufferFiller (AudioConverterRef inAudioConverter, UInt32* ioNumberDataPackets, AudioBufferList* ioData, AudioStreamPacketDescription** outDataPacketDescription, void* inUserData)
{
// or use a previously dynamically-allocated memory block
static AudioStreamPacketDescription aspdesc;


       // ... get some data and error processing
       NSData *data = ...;

   	*ioNumberDataPackets = 1;
   	ioData->mNumberBuffers = 1;
       ioData->mBuffers[0].mDataByteSize = [data length];
       ioData->mBuffers[0].mData = (void *)[data bytes];

       // use the static instance
   	*outDataPacketDescription = &aspdesc;
   	aspdesc.mDataByteSize = [data length];
   	aspdesc.mStartOffset = 0;
   	aspdesc.mVariableFramesInPacket = 1;
       return noErr;
   }

On ther calling side, however, I still pass NULL as the last parameter (AudioStreamPacketDescription* outPacketDescription) to AudioConverterFillComplexBuffer.

d.


_______________________________________________ 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
References: 
 >MP3 Packet Description Problem (From: Mike Simmons <email@hidden>)
 >Re: MP3 Packet Description Problem (From: "Lukhnos D. Liu" <email@hidden>)

  • Prev by Date: Re: Test report MBP built-in audio device
  • Next by Date: Re: afconvert producing 4K stubs in Leopard, but converting properly in Tiger...Need a hand!
  • Previous by thread: Re: MP3 Packet Description Problem
  • Next by thread: Number of bytes buffered.
  • Index(es):
    • Date
    • Thread