• 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
Get number of frames for CAF LPCM for AudioFilePlayer unit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get number of frames for CAF LPCM for AudioFilePlayer unit


  • Subject: Get number of frames for CAF LPCM for AudioFilePlayer unit
  • From: Tim Kemp <email@hidden>
  • Date: Sat, 08 Dec 2012 21:30:01 -0500

I have some stereo audio in lpcm written to a CAF file. I want to play it back using an AUFilePlayer. I set up a region like this:

// Get file length
UInt64 nPackets;
UInt32 nPacketsSize = sizeof(nPackets);
checkError(AudioFileGetProperty(audioFile,
kAudioFilePropertyAudioDataByteCount,
&nPacketsSize,
        &nPackets),
           "ExtAudioFileGetProperty failed: obtaining length of playback file", false);
    
// Setup the region
ScheduledAudioFileRegion rgn;
memset(&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));
rgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
rgn.mTimeStamp.mSampleTime = 0;
rgn.mCompletionProc = NULL;
rgn.mCompletionProcUserData = NULL;
rgn.mAudioFile = audioFile;
rgn.mLoopCount = 1;
rgn.mStartFrame = 0;
rgn.mFramesToPlay = nPackets * fileDesc.mFramesPerPacket;

But it crashes during playback. I think this is because nPackets is always zero (checked right after the AudioFileGetProperty call.) Is there a better way to obtain the number of frames to play? Also, why is nPackets zero here? What should I be looking to check?

Thanks


 _______________________________________________
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

  • Follow-Ups:
    • Re: Get number of frames for CAF LPCM for AudioFilePlayer unit
      • From: Dave Fernandes <email@hidden>
  • Prev by Date: Re: auval -v Silent Flag Error
  • Next by Date: Re: Get number of frames for CAF LPCM for AudioFilePlayer unit
  • Previous by thread: Re: auval -v Silent Flag Error
  • Next by thread: Re: Get number of frames for CAF LPCM for AudioFilePlayer unit
  • Index(es):
    • Date
    • Thread