• 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: playing AAC+ file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: playing AAC+ file


  • Subject: Re: playing AAC+ file
  • From: William Stewart <email@hidden>
  • Date: Thu, 13 Nov 2008 10:31:28 -0800

The problem is in the file itself - the file that you sent us has a meta-data tag at the end of it which is causing our parser to reject it.

While we can fix it for snow leopard (we'll just ignore that illegal data), we won't be able to fix it before then. If you get a properly formed .aac file you shouldn't have any problems

Bill

On Nov 12, 2008, at 7:19 PM, Arnab Ganguly wrote:

Hi All,
I have tried out the below changes and got the following errors

administrators-macbook-pro-3:Debug bdcuser$ ./AQPlay /Users/bdcuser/ song.aac
Playing file: /Users/bdcuser/song.aac
File format: AudioStreamBasicDescription: 2 ch, 24000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame


File format: AudioStreamBasicDescription: 2 ch, 24000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
File has a 2 layered data format:
AudioStreamBasicDescription: 2 ch, 48000 Hz, 'aach' (0x00000000) 0 bits/channel, 0 bytes/packet, 2048 frames/packet, 0 bytes/frame
AudioStreamBasicDescription: 2 ch, 24000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Playing format: AudioStreamBasicDescription: 2 ch, 24000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Buffer Byte Size: 16384, Num Packets to Read: 92
error -40: AudioFileReadPackets failed


Error: AudioFileReadPackets failed (-40)


For MP3 it plays perfectly

administrators-macbook-pro-3:Debug bdcuser$ ./AQPlay /Users/bdcuser/ song.mp3
Playing file: /Users/bdcuser/song.mp3
File format: AudioStreamBasicDescription: 2 ch, 11025 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 576 frames/ packet, 0 bytes/frame
File format: AudioStreamBasicDescription: 2 ch, 11025 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 576 frames/ packet, 0 bytes/frame
Playing format: AudioStreamBasicDescription: 2 ch, 11025 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 576 frames/ packet, 0 bytes/frame
Buffer Byte Size: 16384, Num Packets to Read: 15


It seems the aac file is having two formats what you have explained in your earlier email. Can you tell me the workaround for this also how do I check the format available on my system at run-time?

Thanks in advance
-Arnab

On Tue, Oct 21, 2008 at 1:36 AM, William Stewart <email@hidden> wrote:
you can use aqplay as a starting point (/Developer/Examples/CoreAudio)



Basically - HE-AAC is a layered format - it is a format that has at its core the base layer of AAC. We represent this layering through a notion of a list of formats - that is, the file's data can be rendered in different modes, at different resolutions. For HE, you would have something like (each of these alternatives is published as a different ASBD)


HE-AAC, 44.1KHz, 2 channels (enhanced layer) -> 'aach'
AAC, 22.05KHz, 2 channels (base layer) -> 'aac '

So the file publishes both formats. With HE-AACv2, you would have a list of 3 possible formats:
HE-AACv2, 44.1KHz, 2 channels (enhanced layer 2) -> 'aacp'
HE-AAC, 44.1KHz, 1 channel (enhanced layer 1) -> 'aach'
AAC, 22.05KHz, 1 channel (base layer) -> 'aac '


Then you can see which format is available on the system at run- time, and you chose the richest (or best) currently available format.

For aqplay, the following code will basically work if you add it in between opening the file and creating the audio queue.

UInt32 size;
XThrowIfError(AudioFileGetPropertyInfo(myInfo.mAudioFile,
kAudioFilePropertyFormatList , &size, NULL), "couldn't get file's format list info");
UInt32 numFormats = size / sizeof(AudioFormatListItem);
AudioFormatListItem *formatList = new AudioFormatListItem [ numFormats ];


XThrowIfError(AudioFileGetProperty(myInfo.mAudioFile,
kAudioFilePropertyFormatList , &size, formatList), "couldn't get file's data format");
numFormats = size / sizeof(AudioFormatListItem); // we need to reassess the actual number of formats when we get it
if (numFormats == 1) {
// this is the common case
myInfo.mDataFormat = formatList[0].mASBD;


// see if there is a channel layout (multichannel file)
result = AudioFileGetPropertyInfo(myInfo.mAudioFile, kAudioFilePropertyChannelLayout, &myInfo.mChannelLayoutSize, NULL);
if (result == noErr && myInfo.mChannelLayoutSize > 0) {
myInfo.mChannelLayout = (AudioChannelLayout *)new char [myInfo.mChannelLayoutSize];
XThrowIfError(AudioFileGetProperty(myInfo.mAudioFile, kAudioFilePropertyChannelLayout, &myInfo.mChannelLayoutSize, myInfo.mChannelLayout), "get audio file's channel layout");
}
} else {
printf ("File has a %d layered data format: \n", numFormats);
for (unsigned int i = 0; i < numFormats; ++i)
CAStreamBasicDescription(formatList[i].mASBD).Print();
// now we should look to see which decoders we have on the system
XThrowIfError (AudioFormatGetPropertyInfo(kAudioFormatProperty_DecodeFormatIDs, 0, NULL, &size), "couldn't get decoder id's");
UInt32 numDecoders = size / sizeof(OSType);
OSType *decoderIDs = new OSType [ numDecoders ];
XThrowIfError (AudioFormatGetProperty(kAudioFormatProperty_DecodeFormatIDs, 0, NULL, &size, decoderIDs), "couldn't get decoder id's");
unsigned int i = 0;
for (; i < numFormats; ++i) {
OSType decoderID = formatList[i].mASBD.mFormatID;
bool found = false;
for (unsigned int j = 0; j < numDecoders; ++j) {
if (decoderID == decoderIDs[j]) {
found = true;
break;
}
}
if (found) break;
}
delete [] decoderIDs;


if (i >= numFormats) {
fprintf (stderr, "Cannot play any of the formats in this file\n");
throw kAudioFileUnsupportedDataFormatError;
}
myInfo.mDataFormat = formatList[i].mASBD;
myInfo.mChannelLayoutSize = sizeof(AudioChannelLayout);
myInfo.mChannelLayout = (AudioChannelLayout*)new char [myInfo.mChannelLayoutSize];
myInfo.mChannelLayout->mChannelLayoutTag = formatList[i].mChannelLayoutTag;
myInfo.mChannelLayout->mChannelBitmap = 0;
myInfo.mChannelLayout- >mNumberChannelDescriptions = 0;
}
delete [] formatList;


printf ("Playing format: "); myInfo.mDataFormat.Print();

XThrowIfError(AudioQueueNewOutput(&myInfo.mDataFormat, AQTestBufferCallback, &myInfo,
CFRunLoopGetCurrent (), kCFRunLoopCommonModes, 0, &myInfo.mQueue), "AudioQueueNew failed");



Bill



On Oct 19, 2008, at 4:27 AM, Arnab Ganguly wrote:

Hi All,
I am very new to Coreaudio apis.So need help on where can I find tutorials for writing sample applications using coreaudio apis'.I am planning to write a player in Mac which can play AAC+ files.Any help would be very much appreciated.
Thanks in advance
-A
_______________________________________________
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



_______________________________________________ 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
  • Prev by Date: Re: Playing pls files with core audio
  • Next by Date: Re: Playing pls files with core audio
  • Previous by thread: Re: Playing pls files with core audio
  • Next by thread: Audio Unit PDC / latency troubles
  • Index(es):
    • Date
    • Thread