OSStatus CAAudioChannelLayout::Restore (CFPropertyListRef &inData) { if (CFGetTypeID (inData) != CFDictionaryGetTypeID()) return paramErr; CACFDictionary dict(static_cast<CFDictionaryRef>(inData), false); RefCountedLayout *temp = NULL; AudioChannelLayout* layout; CFArrayRef descs = NULL; UInt32 numDescs = 0; if (dict.GetArray (kACLDescsKey, descs)) { numDescs = CFArrayGetCount (descs); } temp = RefCountedLayout::CreateWithNumberChannelDescriptions(numDescs); layout = temp->GetLayout(); if (!dict.GetUInt32 (kACLTagKey, layout->mChannelLayoutTag)) goto badget; if (dict.HasKey (kACLBitmapKey)) { if (!dict.GetUInt32 (kACLBitmapKey, layout->mChannelBitmap)) goto badget; } else layout->mChannelBitmap = 0; layout->mNumberChannelDescriptions = numDescs; if (numDescs) { AudioChannelDescription *desc = layout->mChannelDescriptions; for (unsigned int i = 0; i < numDescs; ++i, ++desc) { CFDictionaryRef descDict = (CFDictionaryRef)CFArrayGetValueAtIndex (descs, i); CACFDictionary theDesc (descDict, false); if (!theDesc.GetUInt32 (kACLLabelKey, desc->mChannelLabel)) goto badget; if (!theDesc.GetUInt32 (kACLFlagsKey, desc->mChannelFlags)) goto badget; if (!theDesc.GetFloat32 (kACLCoords0Key, desc->mCoordinates[0])) goto badget; if (!theDesc.GetFloat32 (kACLCoords1Key, desc->mCoordinates[1])) goto badget; if (!theDesc.GetFloat32 (kACLCoords2Key, desc->mCoordinates[2])) goto badget; } } if (mLayout) mLayout->release(); mLayout = temp; return noErr; badget: delete temp; return paramErr; }
OSStatus CAAudioChannelLayout::Restore (CFPropertyListRef &inData) { if (CFGetTypeID (inData) != CFDictionaryGetTypeID()) return -1; CACFDictionary dict(static_cast<CFDictionaryRef>(inData), false); ACLRefCounter *temp = NULL; UInt32 size = 0; AudioChannelLayout* layout; UInt32 numDescs; if (!dict.GetUInt32 (kACLDescKey, numDescs)) goto badget; size = numDescs * sizeof (AudioChannelDescription) + offsetof(AudioChannelLayout, mChannelDescriptions[0]); temp = new ACLRefCounter (size); layout = temp->GetLayout(); if (!dict.GetUInt32 (kACLTagKey, layout->mChannelLayoutTag)) goto badget; if (!dict.GetUInt32 (kACLBitmapKey, layout->mChannelBitmap)) goto badget; layout->mNumberChannelDescriptions = numDescs; if (numDescs) { static char string[32]; AudioChannelDescription *desc = layout->mChannelDescriptions; for (unsigned int i = 0; i < numDescs; ++i, ++desc) { sprintf (string, "%d", i); CFDictionaryRef descDict; if (!dict.GetCFTypeWithCStringKey (string, static_cast<const void*>(descDict))) goto badget; CACFDictionary theDesc (descDict, false); if (!theDesc.GetUInt32 (kACLLabelKey, desc->mChannelLabel)) goto badget; if (!theDesc.GetUInt32 (kACLFlagsKey, desc->mChannelFlags)) goto badget; if (!theDesc.GetFloat32 (kACLCoords0Key, desc->mCoordinates[0])) goto badget; if (!theDesc.GetFloat32 (kACLCoords1Key, desc->mCoordinates[1])) goto badget; if (!theDesc.GetFloat32 (kACLCoords2Key, desc->mCoordinates[2])) goto badget; } } if (mLayoutHolder) mLayoutHolder->release(); mLayoutHolder = temp; return noErr; badget: delete temp; return -1; }
void CAAUMIDIMap::Restore(CFDictionaryRef inData) { CACFDictionary paramDict (inData, false); if (!paramDict.GetUInt32 (kLocalScopeStr, mScope)) return; if (!paramDict.GetUInt32 (kLocalElementIDStr, mElement)) return; if (!paramDict.GetUInt32 (kLocalParameterIDStr, mParameterID)) return; if (!paramDict.GetUInt32 (kMIDIFlagsStr, mFlags)) return; if (!paramDict.GetFloat32 (kMIDISubMinStr, mSubRangeMin)) return; if (!paramDict.GetFloat32 (kMIDISubMaxStr, mSubRangeMax)) return; UInt32 data; if (!paramDict.GetUInt32 (kMIDIStatusStr, data)) return; mStatus = data; if (!paramDict.GetUInt32 (kMIDIDataByteStr, data)) return; mData1 = data; }