Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sanity check on AudioEndianAtom usage





We have some audio compression code using SoundConverter which we are feeding input via float values from CoreAudio input. On PPC everything worked fine, but under x86, apparently we need to tell the SC the endianness of the data (i.e., it assumes big endian).

After a bit of googling, I ended up writing the code attached below. It seems to work (tells the SC it can _not_ byte swap the input host-endian float stream when 'decompress'ing it), but I had a few questions:

1) should I put a #pragma around my 'atoms' definition to pack it tightly?
2) does the SoundConverterSetInfo call copy the memory passed in? right now I'm passing bytes from the stack...
3) any other obvious problems? :)



-tim


#ifdef __LITTLE_ENDIAN__
short isLittleEndian = true;
#else
short isLittleEndian = false;
#endif

// Atoms are always big-endian
struct {
AudioEndianAtom endian;
AudioTerminatorAtom terminator;
} atoms;
memset(&atoms, 0, sizeof(atoms));
atoms.endian.size = CFSwapInt32HostToBig(sizeof(atoms.endian));
atoms.endian.atomType = CFSwapInt32HostToBig(kAudioEndianAtomType);
atoms.endian.littleEndian = CFSwapInt16HostToBig(isLittleEndian);
atoms.terminator.size = CFSwapInt32HostToBig(sizeof(atoms.terminator));
atoms.terminator.atomType = CFSwapInt32HostToBig (kAudioTerminatorAtomType);

SoundConverterSetInfo(_soundConverter, siDecompressionParams, &atoms);


_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.