I have an issue with using kAudioStreamPropertyPhysicalFormats to get
physical formats supported by a device. If I use the following code it works
ok.
OSStatus os
= 0;
AudioObjectPropertyAddress inAddr;
inAddr.mSelector =
kAudioStreamPropertyPhysicalFormats;
inAddr.mScope =
kAudioObjectPropertyScopeGlobal;
inAddr.mElement = 0;
UInt32
ioSize;
// os =
AudioObjectGetPropertyDataSize
(this->streamID,&inAddr,0,NULL,&ioSize);
Boolean
writable;
os = AudioStreamGetPropertyInfo (this->streamID,0,kAudioStreamPropertyAvailablePhysicalFormats,&ioSize,&writable);
assert (os
== 0);
int fmtCnt = ioSize /
sizeof
(AudioStreamRangedDescription);
assert
(fmtCnt > 0);
AudioStreamRangedDescription * asrds = (AudioStreamRangedDescription *) malloc
(ioSize);
assert
(asrds != NULL);
// os =
AudioObjectGetPropertyData
(this->streamID,&inAddr,0,NULL,&ioSize,asrds);
os = AudioStreamGetProperty (this->streamID,0,kAudioStreamPropertyAvailablePhysicalFormats,&ioSize,asrds);
assert (os
== 0);
However if I comment
out the 2 AudioStreamGetProperty calls and uncomment
corresponding 2
AudioObjectGetProperty calls instead (this is the new
recommended way), the
returned array of AudioStreamRangedDescription seems
to be garbled. First
returned element appears to be ok but following
elements appear not to
contain meaningful values.
It looks as if there were some struct/array
element alignment
problems.
Thanks/Mikael