// -------------------------------------------------------------------------------------- void SetPrefsWindowHelpTags(WindowRef prefsWindow) { CFBundleRef mainBundle; CFStringRef dataBrowserString, userPaneString, staticTextString; HMHelpContentRec dataBrowserContent, userPaneContent, staticTextContent; ControlID dataBrowserID = {kAppSignature, kIconDataBrowserID}; ControlRef dataBrowser, rootControl, userPane, staticText; UInt16 panelIndex; mainBundle = CFBundleGetMainBundle(); // set the help tag for the data browser dataBrowserString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Window Data Browser"), NULL, mainBundle, NULL); dataBrowserContent.version = kMacHelpVersion; SetRect(&dataBrowserContent.absHotRect, 0, 0, 0, 0); dataBrowserContent.tagSide = kHMDefaultSide; dataBrowserContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; dataBrowserContent.content[kHMMinimumContentIndex].u.tagCFString = dataBrowserString; dataBrowserContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; GetControlByID(prefsWindow, &dataBrowserID, &dataBrowser); HMSetControlHelpContent(dataBrowser, &dataBrowserContent); CFRelease(dataBrowserString); // set the help tags for the user panes userPaneString = CFCopyLocalizedStringFromTableInBundle(CFSTR("User Pane"), NULL, mainBundle, NULL); userPaneContent.version = kMacHelpVersion; SetRect(&userPaneContent.absHotRect, 0, 0, 0, 0); userPaneContent.tagSide = kHMDefaultSide; userPaneContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; userPaneContent.content[kHMMinimumContentIndex].u.tagCFString = userPaneString; userPaneContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; // set the help tags for the static texts staticTextString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Static Text"), NULL, mainBundle, NULL); staticTextContent.version = kMacHelpVersion; SetRect(&staticTextContent.absHotRect, 0, 0, 0, 0); staticTextContent.tagSide = kHMDefaultSide; staticTextContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; staticTextContent.content[kHMMinimumContentIndex].u.tagCFString = staticTextString; staticTextContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; GetRootControl(prefsWindow, &rootControl); for (panelIndex = 1; panelIndex <= kNumberOfRows; panelIndex++) { GetIndexedSubControl(rootControl, panelIndex, &userPane); HMSetControlHelpContent(userPane, &userPaneContent); GetIndexedSubControl(userPane, 1, &staticText); HMSetControlHelpContent(staticText, &staticTextContent); } CFRelease(userPaneString); CFRelease(staticTextString); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // RadioEffectUnit::RadioEffectUnit // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RadioEffectUnit::RadioEffectUnit(AudioUnit Component) : AUEffectBase(Component) { CreateElements(); if (!bGLocalized) { // Because we are in a component, we need to load our bundle by identifier so we can access our localized strings // It is important that the string passed here exactly matches that in the Info.plist Identifier string CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.epicgames.audiounit.radio") ); if (bundle != NULL) { kChebyshevPowerMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevPowerMultiplierName, CFSTR("Localizable"), bundle, CFSTR("")); kChebyshevPowerName = CFCopyLocalizedStringFromTableInBundle(kChebyshevPowerName, CFSTR("Localizable"), bundle, CFSTR("")); kChebyshevMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevMultiplierName, CFSTR("Localizable"), bundle, CFSTR("")); kChebyshevCubedMultiplierName = CFCopyLocalizedStringFromTableInBundle(kChebyshevCubedMultiplierName, CFSTR("Localizable"), bundle, CFSTR("")); } bGLocalized = TRUE; //so never pass the test again... } GFinalBandPassFilter.Initialize( 2000.0f, 400.0f, GetSampleRate() ); SetParameter(RadioParam_ChebyshevPowerMultiplier, kDefaultValue_ChebyshevPowerMultiplier ); SetParameter(RadioParam_ChebyshevPower, kDefaultValue_ChebyshevPower ); SetParameter(RadioParam_ChebyshevMultiplier, kDefaultValue_ChebyshevMultiplier ); SetParameter(RadioParam_ChebyshevCubedMultiplier, kDefaultValue_ChebyshevCubedMultiplier ); }
kim_error kim_os_string_create_localized (kim_string *out_string, kim_string in_string) { kim_error lock_err = kim_os_library_lock_for_bundle_lookup (); kim_error err = lock_err; kim_string string = NULL; CFStringRef cfkey = NULL; if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err) { err = kim_os_string_get_cfstring (in_string, &cfkey); } if (!err && kim_library_allow_home_directory_access ()) { CFStringRef cfstring = NULL; CFBundleRef framework = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos")); CFBundleRef main_bundle = CFBundleGetMainBundle (); if (framework) { cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey, CFSTR ("InfoPlist"), framework, ""); } if (main_bundle && !cfstring) { cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey, CFSTR ("InfoPlist"), main_bundle, ""); } if (!err && cfstring) { err = kim_os_string_create_from_cfstring (&string, cfstring); } if (cfstring) { CFRelease (cfstring); } } if (!err && !string) { err = kim_string_copy (&string, in_string); } if (!err) { *out_string = string; string = NULL; } if (cfkey) { CFRelease (cfkey); } kim_string_free (&string); if (!lock_err) { kim_os_library_unlock_for_bundle_lookup (); } return check_error (err); }
/* The real guts of the description creation functionality. See the header file for the steps this function goes through to compute the description. This function can take a CF or NSError. It's called by NSError for the localizedDescription computation. */ CFStringRef _CFErrorCreateLocalizedDescription(CFErrorRef err) { // First look for kCFErrorLocalizedDescriptionKey; if non-NULL, return that as-is. CFStringRef localizedDesc = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedDescriptionKey); if (localizedDesc) return localizedDesc; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS // Cache the CF bundle since we will be using it for localized strings. CFBundleRef cfBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreFoundation")); if (!cfBundle) { // This should be rare, but has been observed in the wild, due to running out of file descriptors. Normally we might not go to such extremes, but since we want to be able to present reasonable errors even in the case of errors such as running out of file descriptors, why not. This is CFError after all. !!! Be sure to have the same logic here as below for going through various options for fetching the strings. #endif CFStringRef result = NULL, reasonOrDesc; if ((reasonOrDesc = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedFailureReasonKey))) { // First look for kCFErrorLocalizedFailureReasonKey result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("The operation couldn\\U2019t be completed. %@"), reasonOrDesc); } else if ((reasonOrDesc = _CFErrorCopyUserInfoKey(err, kCFErrorDescriptionKey))) { // Then try kCFErrorDescriptionKey result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld - %@)"), CFErrorGetDomain(err), (long)CFErrorGetCode(err), reasonOrDesc); } else { // Last resort, just the domain and code result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld.)"), CFErrorGetDomain(err), (long)CFErrorGetCode(err)); } if (reasonOrDesc) CFRelease(reasonOrDesc); return result; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS } #endif #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS // Then look for kCFErrorLocalizedFailureReasonKey; if there, create a full sentence from that. CFStringRef reason = _CFErrorCopyUserInfoKey(err, kCFErrorLocalizedFailureReasonKey); if (reason) { CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("The operation couldn\\U2019t be completed. %@"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem. The %@ will be replaced by a second sentence which indicates why the operation failed."); CFStringRef result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, reason); CFRelease(operationFailedStr); CFRelease(reason); return result; } // Otherwise, generate a semi-user presentable string from the domain, code, and if available, the presumably non-localized kCFErrorDescriptionKey. CFStringRef result; CFStringRef desc = _CFErrorCopyUserInfoKey(err, kCFErrorDescriptionKey); CFStringRef localizedDomain = CFCopyLocalizedStringFromTableInBundle(CFErrorGetDomain(err), CFSTR("Error"), cfBundle, "These are localized in the comment above"); if (desc) { // We have kCFErrorDescriptionKey, so include that with the error domain and code CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld - %@)"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem, followed by a parenthetical sentence which indicates error domain, code, and a description when there is no other way to present an error to the user. The first %@ indicates the error domain, %ld indicates the error code, and the second %@ indicates the description; so this might become '(Mach error 42 - Server error.)' for instance."); result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, localizedDomain, (long)CFErrorGetCode(err), desc); CFRelease(operationFailedStr); CFRelease(desc); } else { // We don't have kCFErrorDescriptionKey, so just use error domain and code CFStringRef operationFailedStr = CFCopyLocalizedStringFromTableInBundle(CFSTR("The operation couldn\\U2019t be completed. (%@ error %ld.)"), CFSTR("Error"), cfBundle, "A generic error string indicating there was a problem, followed by a parenthetical sentence which indicates error domain and code when there is no other way to present an error to the user. The %@ indicates the error domain while %ld indicates the error code; so this might become '(Mach error 42.)' for instance."); result = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, operationFailedStr, localizedDomain, (long)CFErrorGetCode(err)); CFRelease(operationFailedStr); } CFRelease(localizedDomain); return result; #endif }
// -------------------------------------------------------------------------------------- void SetPrefsDialogHelpTags(DialogRef prefsDialog) { HMHelpContentRec helpContent; CFBundleRef mainBundle; CFStringRef helpString; ControlRef control; SInt16 itemIndex; helpContent.version = kMacHelpVersion; SetRect(&helpContent.absHotRect, 0, 0, 0, 0); // use the current location of the controls helpContent.tagSide = kHMDefaultSide; mainBundle = CFBundleGetMainBundle(); // set the help tag for the data browser helpString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Dialog Data Browser"), NULL, mainBundle, NULL); helpContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; helpContent.content[kHMMinimumContentIndex].u.tagCFString = helpString; helpContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; GetDialogItemAsControl(prefsDialog, iIconDataBrowser, &control); HMSetControlHelpContent(control, &helpContent); // this retains the help string CFRelease(helpString); // so we can safely release it // set the help tags for the user panes helpString = CFCopyLocalizedStringFromTableInBundle(CFSTR("User Pane"), NULL, mainBundle, NULL); helpContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; helpContent.content[kHMMinimumContentIndex].u.tagCFString = helpString; helpContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; for (itemIndex = iUserPane1; itemIndex <= iUserPane10; itemIndex += 2) { GetDialogItemAsControl(prefsDialog, itemIndex, &control); HMSetControlHelpContent(control, &helpContent); } CFRelease(helpString); // set the help tags for the static texts helpString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Static Text"), NULL, mainBundle, NULL); helpContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; helpContent.content[kHMMinimumContentIndex].u.tagCFString = helpString; helpContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; for (itemIndex = iUserPane1 + 1; itemIndex <= iUserPane10 + 1; itemIndex += 2) { GetDialogItemAsControl(prefsDialog, itemIndex, &control); HMSetControlHelpContent(control, &helpContent); } CFRelease(helpString); }
CFStringRef GetSummaryTextBooleanValue(Boolean value) { if (value) return CFCopyLocalizedStringFromTableInBundle( CFSTR("On"), CFSTR("Localizable"), MyGetBundle(), CFSTR("the value of a checkbox when selected")); return CFCopyLocalizedStringFromTableInBundle( CFSTR("Off"), CFSTR("Localizable"), MyGetBundle(), CFSTR("the value of a checkbox when not selected")); }
static CFStringRef GetSummaryTextNAValue() { return CFCopyLocalizedStringFromTableInBundle( CFSTR("N/A"), CFSTR("Localizable"), MyGetBundle(), "Not Applicable (for summary)"); }
void ACShepA52Codec::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) { switch(inPropertyID) { case kAudioCodecPropertyManufacturerCFString: { if (ioPropertyDataSize != sizeof(CFStringRef)) { CODEC_THROW(kAudioCodecBadPropertySizeError); } CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Shepmaster Productions"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } case kAudioCodecPropertyMaximumPacketByteSize: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 3840; //Stolen from liba52 docs } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyRequiresPacketDescription: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyHasVariablePacketByteSizes: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 1; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPacketFrameSize: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 6 * 256; // A frame has 6 blocks of 256 samples } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; default: ACSimpleCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData); } }
//_____________________________________________________________________________ // AUPannerBase::AUPannerBase(AudioComponentInstance inAudioUnit) : AUBase(inAudioUnit, 1, 1), mBypassEffect(false) { { CABundleLocker lock; if (!sLocalized) { CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.audio.units.Components") ); if (bundle != NULL) { kPanner_Azimuth_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Azimuth_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_Elevation_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Elevation_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_Distance_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Distance_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_CoordScale_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_CoordScale_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_RefDistance_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_RefDistance_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); kPanner_Gain_Name = CFCopyLocalizedStringFromTableInBundle(kPanner_Gain_Name, CFSTR("AudioUnits"), bundle, CFSTR("")); } sLocalized = true; } } CreateElements(); SetParameter(kPannerParam_Azimuth, kPannerParamDefault_Azimuth); SetParameter(kPannerParam_Elevation, kPannerParamDefault_Elevation); SetParameter(kPannerParam_Distance, kPannerParamDefault_Distance); SetParameter(kPannerParam_CoordScale, kPannerParamDefault_CoordScale); SetParameter(kPannerParam_RefDistance, kPannerParamDefault_RefDistance); SetParameter(kPannerParam_Gain, kPannerParamDefault_Gain); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // SampleEffectUnit::SampleEffectUnit // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SampleEffectUnit::SampleEffectUnit(AudioUnit component) : AUEffectBase(component) { CreateElements(); if (!sLocalized) { // Because we are in a component, we need to load our bundle by identifier so we can access our localized strings // It is important that the string passed here exactly matches that in the Info.plist Identifier string CFBundleRef bundle = CFBundleGetBundleWithIdentifier( CFSTR("com.acme.audiounit.passthrough") ); if (bundle != NULL) { for (int i = 0; i < kNumberPresets; i++ ) { kPresets[i].presetName = CFCopyLocalizedStringFromTableInBundle( kPresets[i].presetName, // string to localize CFSTR("Localizable"), // strings file to search bundle, // bundle to search CFSTR("")); // no comment } kParameterValueStringsOne = CFCopyLocalizedStringFromTableInBundle(kParameterValueStringsOne, CFSTR("Localizable"), bundle, CFSTR("")); kParameterValueStringsTwo = CFCopyLocalizedStringFromTableInBundle(kParameterValueStringsTwo, CFSTR("Localizable"), bundle, CFSTR("")); kParameterValueStringsThree = CFCopyLocalizedStringFromTableInBundle(kParameterValueStringsThree, CFSTR("Localizable"), bundle, CFSTR("")); kParameterOneName = CFCopyLocalizedStringFromTableInBundle(kParameterOneName, CFSTR("Localizable"), bundle, CFSTR("")); kParameterTwoName = CFCopyLocalizedStringFromTableInBundle(kParameterTwoName, CFSTR("Localizable"), bundle, CFSTR("")); kParameterThree_IndexedName = CFCopyLocalizedStringFromTableInBundle(kParameterThree_IndexedName, CFSTR("Localizable"), bundle, CFSTR("")); kParameterFourName = CFCopyLocalizedStringFromTableInBundle(kParameterFourName, CFSTR("Localizable"), bundle, CFSTR("")); } sLocalized = true; //so never pass the test again... } // example of setting up params... SetParameter(kParam_One, kDefaultValue_ParamOne ); SetParameter(kParam_Two, kDefaultValue_ParamTwo ); SetParameter(kParam_Three_Indexed, kDefaultValue_ParamThree_Indexed ); SetParameter(kParam_Four, kDefaultValue_ParamFour ); SetAFactoryPresetAsCurrent (kPresets[kPresetDefaultIndex]); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AUDiskStreamingCheckbox::AUDiskStreamingCheckbox // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, Point inLocation, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inBase) { Rect r; r.top = inLocation.v; r.bottom = r.top; r.left = inLocation.h; r.right = r.left; // localize as necessary if (!sLocalized) { sLocalized = true; CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); if (mainBundle) { kStringStreamFromDisk = CFCopyLocalizedStringFromTableInBundle( kAUViewLocalizedStringKey_StreamFromDisk, kLocalizedStringTable_AUView, mainBundle, CFSTR("'Stream From Disk' checkbox title string")); } } verify_noerr(CreateCheckBoxControl( GetCarbonWindow(), &r, kStringStreamFromDisk, 0, true, &mControl)); verify_noerr (SetControlFontStyle (mControl, &inFontStyle)); ControlSize smallSize = kControlSizeSmall; verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize)); AUCarbonViewControl::SizeControlToFit(mControl, NULL, &mHeight); if (mHeight < 0) mHeight = 0; EmbedControl(mControl); UInt32 value = 0; UInt32 size = sizeof(value); verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size)); HandlePropertyChange (value); RegisterEvents(); }
extern CFStringRef MyGetCustomTitle (Boolean stillNeeded) { static CFStringRef sTitle = NULL; if (stillNeeded) { if (sTitle == NULL) { // Get the name of the application hosting us. CFBundleRef appBundle = CFBundleGetMainBundle(); if (appBundle) { CFStringRef bundleString = CFBundleGetValueForInfoDictionaryKey( appBundle, CFSTR("CFBundleName")); // We don't get an owning reference here, so make a copy. if (bundleString && (CFGetTypeID(bundleString) == CFStringGetTypeID())) sTitle = CFStringCreateCopy(NULL, bundleString); } } // If that failed, use a resource - we may be hosted by an unbundled app. if (sTitle == NULL) { sTitle = CFCopyLocalizedStringFromTableInBundle ( CFSTR("Web Browser"), CFSTR("Localizable"), MyGetBundle(), "the custom pane title"); } } else { if (sTitle != NULL) { CFRelease (sTitle); sTitle = NULL; } } return sTitle; }
static CFStringRef GetSummaryTextHeaderFooterValue(CFStringRef inStr) { if (!inStr || !CFStringGetLength(inStr)) return CFCopyLocalizedStringFromTableInBundle( CFSTR("(Blank)"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer <blank> (for summary)"); else if (CFEqual(inStr, CFSTR("&T"))) return CFCopyLocalizedStringFromTableInBundle( CFSTR("Title"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer <title> (for summary)"); else if (CFEqual(inStr, CFSTR("&U"))) return CFCopyLocalizedStringFromTableInBundle( CFSTR("URL"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer <url> (for summary)"); else if (CFEqual(inStr, CFSTR("&D"))) return CFCopyLocalizedStringFromTableInBundle( CFSTR("Date"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer <date> (for summary)"); else if (CFEqual(inStr, CFSTR("&P"))) return CFCopyLocalizedStringFromTableInBundle( CFSTR("Page #"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer <page #> (for summary)"); else if (CFEqual(inStr, CFSTR("&PT"))) return CFCopyLocalizedStringFromTableInBundle( CFSTR("Page # of #"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer <page # of #> (for summary)"); else return CFRetain(inStr); }
extern OSStatus MyEmbedCustomControls ( MyCustomContext context, WindowRef nibWindow, ControlRef userPane ) { static const ControlID containerControlID = { kMozPDECreatorCode, 4000 }; static const ControlID radioGroupControlID = { kMozPDECreatorCode, 4001 }; static const ControlID printSelCheckControlID = { kMozPDECreatorCode, 4002 }; static const ControlID shrinkToFitCheckControlID = { kMozPDECreatorCode, 4003 }; static const ControlID printBGColorsCheckControlID = { kMozPDECreatorCode, 4004 }; static const ControlID printBGImagesCheckControlID = { kMozPDECreatorCode, 4005 }; static const ControlID headerLeftPopupControlID = { kMozPDECreatorCode, 4006 }; static const ControlID headerCenterPopupControlID = { kMozPDECreatorCode, 4007 }; static const ControlID headerRightPopupControlID = { kMozPDECreatorCode, 4008 }; static const ControlID footerLeftPopupControlID = { kMozPDECreatorCode, 4009 }; static const ControlID footerCenterPopupControlID = { kMozPDECreatorCode, 4010 }; static const ControlID footerRightPopupControlID = { kMozPDECreatorCode, 4011 }; OSStatus result = noErr; if (context != NULL) { ControlHandle paneControl = NULL; // The control we're embedding into the given // userPane is itself a user pane control. result = MyEmbedControl(nibWindow, userPane, &containerControlID, &paneControl); if (paneControl) { WindowRef controlOwner = GetControlOwner(paneControl); GetControlByID(controlOwner, &radioGroupControlID, &(context->controls.frameRadioGroup)); if (context->controls.frameRadioGroup != NULL) { // It doesn't seem to be possible to specify the titles of the // radio buttons within a radio group control, so do it by hand :-/ // This is not done as a loop, but instead using CFSTR("abc") so // that genstrings can grok this file. Maybe that's not worth it? CFStringRef radioTitle; ControlRef radioControl; if (GetIndexedSubControl(context->controls.frameRadioGroup, kFramesAsLaidOutIndex, &radioControl) == noErr) { radioTitle = CFCopyLocalizedStringFromTableInBundle( CFSTR("As laid out on the screen"), CFSTR("Localizable"), MyGetBundle(), "top radio title"); if (radioTitle) { SetControlTitleWithCFString(radioControl, radioTitle); CFRelease(radioTitle); } } if (GetIndexedSubControl(context->controls.frameRadioGroup, kFramesSelectedIndex, &radioControl) == noErr) { radioTitle = CFCopyLocalizedStringFromTableInBundle( CFSTR("The selected frame"), CFSTR("Localizable"), MyGetBundle(), "middle radio title"); if (radioTitle) { SetControlTitleWithCFString(radioControl, radioTitle); CFRelease(radioTitle); } } if (GetIndexedSubControl(context->controls.frameRadioGroup, kFramesEachSeparatelyIndex, &radioControl) == noErr) { radioTitle = CFCopyLocalizedStringFromTableInBundle( CFSTR("Each frame separately"), CFSTR("Localizable"), MyGetBundle(), "bottom radio title"); if (radioTitle) { SetControlTitleWithCFString(radioControl, radioTitle); CFRelease(radioTitle); } } } GetControlByID(controlOwner, &printSelCheckControlID, &(context->controls.printSelCheck)); GetControlByID(controlOwner, &shrinkToFitCheckControlID, &(context->controls.shrinkToFitCheck)); GetControlByID(controlOwner, &printBGColorsCheckControlID, &(context->controls.printBGColorsCheck)); GetControlByID(controlOwner, &printBGImagesCheckControlID, &(context->controls.printBGImagesCheck)); GetControlByID(controlOwner, &headerLeftPopupControlID, &(context->controls.headerLeftPopup)); GetControlByID(controlOwner, &headerCenterPopupControlID, &(context->controls.headerCenterPopup)); GetControlByID(controlOwner, &headerRightPopupControlID, &(context->controls.headerRightPopup)); GetControlByID(controlOwner, &footerLeftPopupControlID, &(context->controls.footerLeftPopup)); GetControlByID(controlOwner, &footerCenterPopupControlID, &(context->controls.footerCenterPopup)); GetControlByID(controlOwner, &footerRightPopupControlID, &(context->controls.footerRightPopup)); // Now that the controls are in, sync with data. SyncPaneFromSettings(context); } } return result; }
void CASpeexDecoder::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) { dbg_printf(" >> [%08lx] CASpeexDecoder :: GetProperty('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID)); switch(inPropertyID) { case kAudioCodecPropertyRequiresPacketDescription: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 1; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyHasVariablePacketByteSizes: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 1; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPacketFrameSize: if(ioPropertyDataSize == sizeof(UInt32)) { UInt32 *outProp = reinterpret_cast<UInt32*>(outPropertyData); if (!mCompressionInitialized) *outProp = kSpeexFramesPerPacket; else if (mSpeexHeader.frame_size != 0 * mSpeexHeader.frames_per_packet != 0) *outProp = mSpeexHeader.frame_size * mSpeexHeader.frames_per_packet; else *outProp = 8192; if (*outProp < 8192 && mInputFormat.mFormatID == kAudioFormatXiphOggFramedSpeex) *outProp = 8192; dbg_printf(" = [%08lx] CASpeexDecoder :: GetProperty('pakf'): %ld\n", (UInt32) this, *outProp); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; //case kAudioCodecPropertyQualitySetting: ??? #if TARGET_OS_MAC case kAudioCodecPropertyNameCFString: { if (ioPropertyDataSize != sizeof(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError); CABundleLocker lock; CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Xiph Speex decoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } //case kAudioCodecPropertyManufacturerCFString: #endif default: ACBaseCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData); } dbg_printf("<.. [%08lx] CASpeexDecoder :: GetProperty('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID)); }
CFNetDiagnosticStatus CFNetDiagnosticCopyNetworkStatusPassively(CFNetDiagnosticRef details, CFStringRef *description) { CFMutableDictionaryRef detailsDict = (CFMutableDictionaryRef)details; CFNetDiagnosticStatus retval = kCFNetDiagnosticConnectionIndeterminate; CFStringRef serviceID; SCDynamicStoreRef store; store = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("CFNetDiagnostics"), NULL, NULL); if(store) { serviceID = CFDictionaryGetValue(detailsDict, _CFNetDiagnosticServiceIDKey); if(serviceID) { //If there is a specific ServiceID we only scan on it. We can only get in this position through SPIs retval = _CFNetDiagnosticCopyNetworkStatusPassivelyInterfaceSpecific(store, serviceID, description); } else { //Iterate through all serviceIDs. If any are good, then we return it CFStringRef pattern = NULL; CFDictionaryRef dict = NULL; CFArrayRef serviceOrder = NULL; CFIndex i, count; CFNetDiagnosticStatus serviceState = kCFNetDiagnosticConnectionDown; pattern = SCDynamicStoreKeyCreateNetworkGlobalEntity( NULL, (CFStringRef) kSCDynamicStoreDomainSetup, (CFStringRef) kSCEntNetIPv4 ); if(pattern) { dict = SCDynamicStoreCopyValue( store, pattern ); CFRelease( pattern ); } if(dict) { serviceOrder = CFDictionaryGetValue(dict, CFSTR("ServiceOrder")); CFRetain(serviceOrder); CFRelease(dict); } if(serviceOrder) { count = CFArrayGetCount(serviceOrder); retval = kCFNetDiagnosticConnectionDown; for ( i = 0; i < count; i++ ) { serviceID = CFArrayGetValueAtIndex(serviceOrder, i); serviceState = _CFNetDiagnosticCopyNetworkStatusPassivelyInterfaceSpecific(store, serviceID, description); if(serviceState == kCFNetDiagnosticConnectionDown) { retval = kCFNetDiagnosticConnectionDown; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("CONNECTION_DOWN"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "This computer's Internet connect appears to be offline."); } } else if (serviceState == kCFNetDiagnosticConnectionIndeterminate) { retval = kCFNetDiagnosticConnectionIndeterminate; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("CONNECTION_INDETERMINATE"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "This computer's Internet may be offline."); } } else if (serviceState == kCFNetDiagnosticConnectionUp) { retval = kCFNetDiagnosticConnectionUp; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("CONNECTION_UP"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "This computer's Internet may be online."); } break; } else { //FIXME //NOT REACHED log an error } } CFRelease(serviceOrder); } } CFRelease(store); } return retval; }
void ACBaseCodec::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) { UInt32 thePacketsToGet; switch(inPropertyID) { case kAudioCodecPropertyNameCFString: { if (ioPropertyDataSize != SizeOf32(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError); CABundleLocker lock; CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("unknown codec"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } case kAudioCodecPropertyManufacturerCFString: { if (ioPropertyDataSize != SizeOf32(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError); CABundleLocker lock; CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Apple, Inc."), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } case kAudioCodecPropertyRequiresPacketDescription: if(ioPropertyDataSize == SizeOf32(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyMinimumNumberInputPackets : if(ioPropertyDataSize != SizeOf32(UInt32)) CODEC_THROW(kAudioCodecBadPropertySizeError); *(UInt32*)outPropertyData = 1; break; case kAudioCodecPropertyMinimumNumberOutputPackets : if(ioPropertyDataSize != SizeOf32(UInt32)) CODEC_THROW(kAudioCodecBadPropertySizeError); *(UInt32*)outPropertyData = 1; break; case kAudioCodecPropertyCurrentInputFormat: if(ioPropertyDataSize == SizeOf32(AudioStreamBasicDescription)) { GetCurrentInputFormat(*reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData)); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertySupportedInputFormats: case kAudioCodecPropertyInputFormatsForOutputFormat: thePacketsToGet = ioPropertyDataSize / SizeOf32(AudioStreamBasicDescription); GetSupportedInputFormats(reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData), thePacketsToGet); ioPropertyDataSize = thePacketsToGet * SizeOf32(AudioStreamBasicDescription); break; case kAudioCodecPropertyCurrentOutputFormat: if(ioPropertyDataSize == SizeOf32(AudioStreamBasicDescription)) { GetCurrentOutputFormat(*reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData)); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertySupportedOutputFormats: case kAudioCodecPropertyOutputFormatsForInputFormat: thePacketsToGet = ioPropertyDataSize / SizeOf32(AudioStreamBasicDescription); GetSupportedOutputFormats(reinterpret_cast<AudioStreamBasicDescription*>(outPropertyData), thePacketsToGet); ioPropertyDataSize = thePacketsToGet * SizeOf32(AudioStreamBasicDescription); break; case kAudioCodecPropertyMagicCookie: if(ioPropertyDataSize >= GetMagicCookieByteSize()) { GetMagicCookie(outPropertyData, ioPropertyDataSize); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyInputBufferSize: if(ioPropertyDataSize == SizeOf32(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = GetInputBufferByteSize(); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyUsedInputBufferSize: if(ioPropertyDataSize == SizeOf32(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = GetUsedInputBufferByteSize(); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyIsInitialized: if(ioPropertyDataSize == SizeOf32(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = IsInitialized() ? 1 : 0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyAvailableNumberChannels: if(ioPropertyDataSize == SizeOf32(UInt32) * 2) { (reinterpret_cast<UInt32*>(outPropertyData))[0] = 1; (reinterpret_cast<UInt32*>(outPropertyData))[1] = 2; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPrimeMethod: if(ioPropertyDataSize == SizeOf32(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = (UInt32)kAudioCodecPrimeMethod_None; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPrimeInfo: if(ioPropertyDataSize == SizeOf32(AudioCodecPrimeInfo) ) { (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->leadingFrames = 0; (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->trailingFrames = 0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyDoesSampleRateConversion: if(ioPropertyDataSize == SizeOf32(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; default: CODEC_THROW(kAudioCodecUnknownPropertyError); break; }; }
CFNetDiagnosticStatus CFNetDiagnosticCopyNetworkStatusActively(CFNetDiagnosticRef details, CFNumberRef timeout, CFStringRef *description) { uint64_t timestamp; uint32_t timeout_value; uint32_t running_timeout; struct mach_timebase_info timebase; CFNetDiagnosticStatus retval = kCFNetDiagnosticConnectionDown; kern_return_t err; double conversion_factor; CFStringRef pingTarget; CFArrayRef nameServers; CFIndex nameServerCount; CFIndex i; bool nameServerResponded; //Get a timestamp timestamp = mach_absolute_time(); err = mach_timebase_info(&timebase); if(err == KERN_SUCCESS) { conversion_factor = 1e-9 * (double)(timebase.numer) / (double)(timebase.denom); retval = CFNetDiagnosticCopyNetworkStatusPassively(details, description); if (retval != kCFNetDiagnosticConnectionUp) { if (CFNumberGetValue(timeout, kCFNumberIntType, &timeout_value)) { //Get current time remaining running_timeout = timeout_value - conversion_factor * (mach_absolute_time() - timestamp); pingTarget = copyCurrentRouter(); if (pingTarget) { if(_CFNetDiagnosticPing(pingTarget, 1, running_timeout)) { CFRelease(pingTarget); retval = kCFNetDiagnosticConnectionDown; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("ROUTER_DOWN"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "This computer's router is not responding."); } } else { CFRelease(pingTarget); nameServers = copyCurrentDNSServers(); if (nameServers) { nameServerCount = CFArrayGetCount(nameServers); //Get current time remaining running_timeout = ((timeout_value - conversion_factor * (mach_absolute_time() - timestamp)) / nameServerCount); //ping a nameserver nameServerResponded = false; for (i=0; i < nameServerCount; i++) { pingTarget = CFArrayGetValueAtIndex(nameServers, i); if (!nameServerResponded) { if(!_CFNetDiagnosticPing(pingTarget, 1, running_timeout)) { nameServerResponded = true; } } } CFRelease(nameServers); if (!nameServerResponded) { retval = kCFNetDiagnosticConnectionDown; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("NAMESERVER_DOWN"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "This computer's DNS server is not responding."); } } else { //Get current time remaining running_timeout = timeout_value - conversion_factor * (mach_absolute_time() - timestamp); //Server router pingTarget = CFDictionaryGetValue((CFDictionaryRef)details, _CFNetDiagnosticRemoteHostKey); if(pingTarget) { if (_CFNetDiagnosticPing(pingTarget, 1, running_timeout)) { retval = kCFNetDiagnosticConnectionDown; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("SERVER_DOWN"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "The server this computer is attempting to connect to is not responding."); } } else { retval = kCFNetDiagnosticConnectionUp; if (description) { *description = CFCopyLocalizedStringFromTableInBundle( CFSTR("SERVER_UP"), NULL, CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CFNetwork")), "This computer's Internet connection appears ot be online."); } } } } } } } } } } //FIXME return retval; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AURenderQualityPopup::AURenderQualityPopup // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AURenderQualityPopup::AURenderQualityPopup (AUCarbonViewBase *inBase, Point inLocation, int inRightEdge, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inBase) { Rect r; r.top = inLocation.v; r.bottom = r.top + 17; r.left = inLocation.h; r.right = r.left + inRightEdge; ControlFontStyleRec fontStyle = inFontStyle; inFontStyle.just = teFlushRight; ControlRef ref; CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.audio.units.Components")); if (mainBundle != NULL) { CFMutableStringRef renderTitle = CFStringCreateMutable(NULL, 0); CFStringAppend(renderTitle, CFCopyLocalizedStringFromTableInBundle( CFSTR("Render Quality"), CFSTR("CustomUI"), mainBundle, CFSTR("The Render Quality Popup menu title"))); CFStringAppend(renderTitle, CFSTR(":")); OSErr theErr = CreateStaticTextControl (GetCarbonWindow(), &r, renderTitle, &inFontStyle, &ref); if (theErr == noErr) EmbedControl(ref); r.left = r.right + 8; r.right = r.left + 100; short bundleRef = CFBundleOpenBundleResourceMap (mainBundle); theErr = CreatePopupButtonControl (mView->GetCarbonWindow(), &r, NULL, /*kQualityMenuID*/ -12345, false, -1, 0, 0, &mControl); MenuRef menuRef; verify_noerr(CreateNewMenu(kQualityMenuID, 0, &menuRef)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Maximum"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("High"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Medium"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Low"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Minimum"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(SetControlData(mControl, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef)); verify_noerr(SetControlFontStyle (mControl, &inFontStyle)); SetControl32BitMaximum(mControl, 5); UInt32 renderQuality; UInt32 size = sizeof(UInt32); AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_RenderQuality, kAudioUnitScope_Global, 0, &renderQuality, &size); HandlePropertyChange(renderQuality); EmbedControl(mControl); theErr = AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kAudioUnitProperty_RenderQuality, RenderQualityListener, this); CFBundleCloseBundleResourceMap (mainBundle, bundleRef); CFRelease(renderTitle); } RegisterEvents(); }
void ACFLACEncoder::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) { switch(inPropertyID) { case kAudioCodecPropertyNameCFString: { if (ioPropertyDataSize != sizeof(CFStringRef)) { CODEC_THROW(kAudioCodecBadPropertySizeError); } CABundleLocker lock; CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("FLAC encoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } case kAudioCodecPropertyAvailableNumberChannels: if(ioPropertyDataSize == sizeof(UInt32) * kFLACNumberSupportedChannelTotals) { memcpy(reinterpret_cast<UInt32*>(outPropertyData), mSupportedChannelTotals, ioPropertyDataSize); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyAvailableInputSampleRates: if(ioPropertyDataSize == sizeof(AudioValueRange) ) { (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMinimum = 0.0; (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMaximum = 0.0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyAvailableOutputSampleRates: if(ioPropertyDataSize == sizeof(AudioValueRange) ) { (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMinimum = 0.0; (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMaximum = 0.0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPrimeMethod: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = (UInt32)kAudioCodecPrimeMethod_None; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPrimeInfo: if(ioPropertyDataSize == sizeof(AudioCodecPrimeInfo) ) { (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->leadingFrames = 0; (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->trailingFrames = mTrailingFrames; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyQualitySetting: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = mQuality; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyMaximumPacketByteSize: if(ioPropertyDataSize == sizeof(UInt32)) { if (mMaxFrameBytes) { *reinterpret_cast<UInt32*>(outPropertyData) = mMaxFrameBytes; } else // default case { *reinterpret_cast<UInt32*>(outPropertyData) = mMaxFrameBytes = kInputBufferPackets * mOutputFormat.mChannelsPerFrame * (mBitDepth >> 3) + kMaxEscapeHeaderBytes; } #if VERBOSE printf("Max packet size == %lu, mBitDepth == %lu\n", mMaxFrameBytes, mBitDepth); #endif } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecInputFormatsForOutputFormat: if(ioPropertyDataSize >= sizeof(AudioStreamBasicDescription)) { UInt32 bitDepth, numFormats = 1, tempSize; switch ( ( ( (AudioStreamBasicDescription*)(outPropertyData) )[0].mFormatFlags) & 0x00000007) { case kFLACFormatFlag_16BitSourceData: bitDepth = 16; break; case kFLACFormatFlag_20BitSourceData: bitDepth = 24; break; case kFLACFormatFlag_24BitSourceData: bitDepth = 24; break; case kFLACFormatFlag_32BitSourceData: bitDepth = 32; break; default: // Check the currently set input format bit depth bitDepth = mInputFormat.mBitsPerChannel; numFormats = 2; break; } AudioStreamBasicDescription theInputFormat = {kAudioStreamAnyRate, kAudioFormatLinearPCM, kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked, 0, 1, 0, 0, bitDepth, 0}; tempSize = sizeof(AudioStreamBasicDescription) * numFormats; if ( tempSize <= ioPropertyDataSize ) { ioPropertyDataSize = tempSize; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } if ( numFormats == 1 ) { memcpy(outPropertyData, &theInputFormat, ioPropertyDataSize); } else // numFormats == 2 { theInputFormat.mBitsPerChannel = 16; memcpy(outPropertyData, &theInputFormat, sizeof(AudioStreamBasicDescription)); theInputFormat.mBitsPerChannel = 24; memcpy((void *)((Byte *)outPropertyData + sizeof(AudioStreamBasicDescription)), &theInputFormat, sizeof(AudioStreamBasicDescription)); } } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyZeroFramesPadded: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 0; // we never append any extra zeros } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertySettings: if(ioPropertyDataSize == sizeof(CFDictionaryRef *) ) { BuildSettingsDictionary(reinterpret_cast<CFDictionaryRef *>(outPropertyData) ); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; default: ACFLACCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData); }
void ACFLACCodec::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) { // kAudioCodecPropertyMaximumPacketByteSize is handled in the Encoder or Decoder switch(inPropertyID) { case kAudioCodecPropertyFormatCFString: { if (ioPropertyDataSize != sizeof(CFStringRef)) { CODEC_THROW(kAudioCodecBadPropertySizeError); } CABundleLocker lock; CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("FLAC"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } case kAudioCodecPropertyRequiresPacketDescription: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 1; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyHasVariablePacketByteSizes: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = 1; // We are variable bitrate } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPacketFrameSize: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = kFramesPerPacket; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyMagicCookie: if(ioPropertyDataSize >= GetMagicCookieByteSize()) { GetMagicCookie(outPropertyData, ioPropertyDataSize); mMagicCookieLength = ioPropertyDataSize; } else { CODEC_THROW(kAudioCodecIllegalOperationError); } break; case kAudioCodecPropertyCurrentInputSampleRate: if(ioPropertyDataSize == sizeof(Float64)) { *reinterpret_cast<Float64*>(outPropertyData) = (Float64)(mInputFormat.mSampleRate); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyCurrentOutputSampleRate: if(ioPropertyDataSize == sizeof(Float64)) { *reinterpret_cast<Float64*>(outPropertyData) = (Float64)(mOutputFormat.mSampleRate); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyInputChannelLayout: case kAudioCodecPropertyOutputChannelLayout: AudioChannelLayout temp1AudioChannelLayout; memset(&temp1AudioChannelLayout, 0, sizeof(AudioChannelLayout)); if(ioPropertyDataSize == sizeof(AudioChannelLayout)) { temp1AudioChannelLayout.mChannelLayoutTag = sChannelLayoutTags[mInputFormat.mChannelsPerFrame - 1]; memcpy(outPropertyData, &temp1AudioChannelLayout, ioPropertyDataSize); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyAvailableInputChannelLayouts: case kAudioCodecPropertyAvailableOutputChannelLayouts: if(ioPropertyDataSize == kMaxChannels * sizeof(AudioChannelLayoutTag)) { if(mIsInitialized) { AudioChannelLayoutTag temp2AudioChannelLayout[1]; temp2AudioChannelLayout[0] = sChannelLayoutTags[mInputFormat.mChannelsPerFrame - 1]; ioPropertyDataSize = sizeof(AudioChannelLayoutTag); memcpy(reinterpret_cast<AudioChannelLayoutTag*>(outPropertyData), temp2AudioChannelLayout, ioPropertyDataSize); } else { AudioChannelLayoutTag tempAudioChannelLayout[kMaxChannels]; tempAudioChannelLayout[0] = kAudioChannelLayoutTag_Mono; tempAudioChannelLayout[1] = kAudioChannelLayoutTag_Stereo; tempAudioChannelLayout[2] = kAudioChannelLayoutTag_MPEG_3_0_B; tempAudioChannelLayout[3] = kAudioChannelLayoutTag_MPEG_4_0_B; tempAudioChannelLayout[4] = kAudioChannelLayoutTag_MPEG_5_0_D; tempAudioChannelLayout[5] = kAudioChannelLayoutTag_MPEG_5_1_D; tempAudioChannelLayout[6] = kAudioChannelLayoutTag_AAC_6_1; tempAudioChannelLayout[7] = kAudioChannelLayoutTag_MPEG_7_1_B; memcpy(reinterpret_cast<AudioChannelLayoutTag*>(outPropertyData), tempAudioChannelLayout, ioPropertyDataSize); } } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyFormatInfo: if(ioPropertyDataSize == sizeof(AudioFormatInfo)) { AudioFormatInfo& formatInfo = *(AudioFormatInfo*)outPropertyData; // Check for cookie existence if((NULL != formatInfo.mMagicCookie) && (formatInfo.mMagicCookieSize > 0)) { UInt32 theByteSize = formatInfo.mMagicCookieSize; FLAC__StreamMetadata_StreamInfo theConfig; memset (&theConfig, 0, sizeof(FLAC__StreamMetadata_StreamInfo)); ParseMagicCookie(formatInfo.mMagicCookie, theByteSize, &theConfig); formatInfo.mASBD.mSampleRate = (Float64)theConfig.sample_rate; formatInfo.mASBD.mChannelsPerFrame = theConfig.channels; formatInfo.mASBD.mFramesPerPacket = theConfig.max_blocksize; formatInfo.mASBD.mBytesPerPacket = 0; // it's never CBR switch (theConfig.bits_per_sample) { case 16: formatInfo.mASBD.mFormatFlags = kFLACFormatFlag_16BitSourceData; break; case 20: formatInfo.mASBD.mFormatFlags = kFLACFormatFlag_20BitSourceData; break; case 24: formatInfo.mASBD.mFormatFlags = kFLACFormatFlag_24BitSourceData; break; case 32: formatInfo.mASBD.mFormatFlags = kFLACFormatFlag_32BitSourceData; break; default: // we don't support this formatInfo.mASBD.mFormatFlags = 0; break; } } else { // We don't have a cookie, we have to check the ASBD // according to the input formats UInt32 i; for(i = 0; i < GetNumberSupportedInputFormats(); ++i) { if(mInputFormatList[i].IsEqual(formatInfo.mASBD)) { // IsEqual will treat 0 values as wildcards -- we can't have that with the format flags UInt32 tempFormatFlags = formatInfo.mASBD.mFormatFlags; // Fill out missing entries CAStreamBasicDescription::FillOutFormat(formatInfo.mASBD, mInputFormatList[i]); if (tempFormatFlags == 0) { formatInfo.mASBD.mFormatFlags = 0; // anything assigned here would be bad. } break; } } if(i == GetNumberSupportedInputFormats()) { // No suitable settings found CODEC_THROW(kAudioCodecUnsupportedFormatError); } } } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; default: ACBaseCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData); } }
AUVPresets::AUVPresets (AUCarbonViewBase* inParentView, CFArrayRef& inPresets, Point inLocation, int nameWidth, int controlWidth, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inParentView), mPresets (inPresets), mView (inParentView) { #if !__LP64__ Rect r; // ok we now have an array of factory presets // get their strings and display them r.top = inLocation.v; r.bottom = r.top; r.left = inLocation.h; r.right = r.left; // localize as necessary if (!sAUVPresetLocalized) { CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); if (mainBundle) { kStringFactoryPreset = CFCopyLocalizedStringFromTableInBundle( kAUViewLocalizedStringKey_FactoryPreset, kLocalizedStringTable_AUView, mainBundle, CFSTR("FactoryPreset title string")); sAUVPresetLocalized = true; } } // create localized title string CFMutableStringRef factoryPresetsTitle = CFStringCreateMutable(NULL, 0); CFStringAppend(factoryPresetsTitle, kStringFactoryPreset); CFStringAppend(factoryPresetsTitle, kAUViewUnlocalizedString_TitleSeparator); ControlRef theControl; verify_noerr(CreateStaticTextControl(mView->GetCarbonWindow(), &r, factoryPresetsTitle, &inFontStyle, &theControl)); SInt16 width = 0; AUCarbonViewControl::SizeControlToFit(theControl, &width, &mHeight); CFRelease(factoryPresetsTitle); EmbedControl(theControl); r.top -= 2; r.left += width + 10; r.right = r.left; r.bottom = r.top; verify_noerr(CreatePopupButtonControl ( mView->GetCarbonWindow(), &r, NULL, -12345, // DON'T GET MENU FROM RESOURCE mMenuID,!!! FALSE, // variableWidth, 0, // titleWidth, 0, // titleJustification, 0, // titleStyle, &mControl)); MenuRef menuRef; verify_noerr(CreateNewMenu(1, 0, &menuRef)); int numPresets = CFArrayGetCount(mPresets); for (int i = 0; i < numPresets; ++i) { AUPreset* preset = (AUPreset*) CFArrayGetValueAtIndex (mPresets, i); verify_noerr(AppendMenuItemTextWithCFString (menuRef, preset->presetName, 0, 0, 0)); } verify_noerr(SetControlData(mControl, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef)); verify_noerr (SetControlFontStyle (mControl, &inFontStyle)); SetControl32BitMaximum (mControl, numPresets); // size popup SInt16 height = 0; AUCarbonViewControl::SizeControlToFit(mControl, &width, &height); if (height > mHeight) mHeight = height; if (mHeight < 0) mHeight = 0; // find which menu item is the Default preset UInt32 propertySize = sizeof(AUPreset); AUPreset defaultPreset; OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_PresentPreset, kAudioUnitScope_Global, 0, &defaultPreset, &propertySize); mPropertyID = kAudioUnitProperty_PresentPreset; #endif #ifndef __LP64__ if (result != noErr) { // if the PresentPreset property is not implemented, fall back to the CurrentPreset property OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_CurrentPreset, kAudioUnitScope_Global, 0, &defaultPreset, &propertySize); mPropertyID = kAudioUnitProperty_CurrentPreset; if (result == noErr) CFRetain (defaultPreset.presetName); } #endif #if !__LP64__ EmbedControl (mControl); HandlePropertyChange(defaultPreset); RegisterEvents(); #endif }
// -------------------------------------------------------------------------------------- static DataBrowserItemID addItemsToIconDB(ControlRef iconDataBrowser, ControlRef *userPanes) { IconDBItemDataRec *itemsData, *rowItemData; CFBundleRef mainBundle; CFIndex rowNumber; DataBrowserItemID items[kNumberOfRows]; CFStringRef catNameKeys[kNumberOfRows]; itemsData = CFAllocatorAllocate(kCFAllocatorDefault, kNumberOfRows * sizeof(IconDBItemDataRec), 0); mainBundle = CFBundleGetMainBundle(); if (!gIconsRegistered) // if we didn't register our icons already, we need to { CFArrayRef iconURLs; FSRef iconFile; FSSpec iconSpec; iconURLs = CFBundleCopyResourceURLsOfType(mainBundle, CFSTR("icns"), CFSTR("PrefCategories")); for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++) { CFURLGetFSRef(CFArrayGetValueAtIndex(iconURLs, rowNumber), &iconFile); #if TARGET_API_MAC_OSX #pragma unused (iconSpec) RegisterIconRefFromFSRef(kAppSignature, 'Cat0' + rowNumber, &iconFile, &((itemsData + rowNumber)->icon)); #else FSGetCatalogInfo(&iconFile, kFSCatInfoNone, NULL, NULL, &iconSpec, NULL); RegisterIconRefFromIconFile(kAppSignature, 'Cat0' + rowNumber, &iconSpec, &((itemsData + rowNumber)->icon)); #endif } CFRelease(iconURLs); gIconsRegistered = true; } else // the icons are already registered so we just have to get them { for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++) { GetIconRef(kOnSystemDisk, kAppSignature, 'Cat0' + rowNumber, &((itemsData + rowNumber)->icon)); } } catNameKeys[0] = CFSTR("Panel 1"); // this is necessary because you have to use catNameKeys[1] = CFSTR("Panel 2"); // constant strings with CFSTR catNameKeys[2] = CFSTR("Panel 3"); // if we didn't do this then we couldn't get catNameKeys[3] = CFSTR("Panel 4"); // the strings in a loop catNameKeys[4] = CFSTR("Panel 5"); catNameKeys[5] = CFSTR("Panel 6"); catNameKeys[6] = CFSTR("Panel 7"); catNameKeys[7] = CFSTR("Panel 8"); catNameKeys[8] = CFSTR("Panel 9"); catNameKeys[9] = CFSTR("Panel 10"); for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++) // now get the names { // and set the user panes rowItemData = itemsData + rowNumber; items[rowNumber] = (DataBrowserItemID)rowItemData; /* We use CFCopyLocalilzedStringFromTableInBundle here instead of CFCopyLocalizedString to avoid a call to CFBundleGetMainBundle every trip around the loop. */ rowItemData->name = CFCopyLocalizedStringFromTableInBundle(catNameKeys[rowNumber], NULL, mainBundle, NULL); rowItemData->userPane = *(userPanes + rowNumber); } AddDataBrowserItems(iconDataBrowser, kDataBrowserNoItem, kNumberOfRows, items, kDataBrowserItemNoProperty); return *items; }
extern OSStatus MyGetSummaryText ( MyCustomContext context, CFMutableArrayRef titleArray, CFMutableArrayRef valueArray ) { CFStringRef title = NULL; CFStringRef value = NULL; CFStringRef format = NULL; OSStatus result = noErr; // "Print Frames" Radio Group title = CFCopyLocalizedStringFromTableInBundle ( CFSTR("Print Frames"), CFSTR("Localizable"), MyGetBundle(), "the Print Frames radio group (for summary)"); if (title != NULL) { if (context->settings.mHaveFrames) { if (context->settings.mPrintFrameAsIs) value = CFCopyLocalizedStringFromTableInBundle( CFSTR("As laid out on the screen"), CFSTR("Localizable"), MyGetBundle(), "Print Frames choice #1 (for summary)"); else if (context->settings.mPrintSelectedFrame) value = CFCopyLocalizedStringFromTableInBundle( CFSTR("The selected frame"), CFSTR("Localizable"), MyGetBundle(), "Print Frames choice #2 (for summary)"); else if (context->settings.mPrintFramesSeparately) value = CFCopyLocalizedStringFromTableInBundle( CFSTR("Each frame separately"), CFSTR("Localizable"), MyGetBundle(), "Print Frames choice #3 (for summary)"); } else value = GetSummaryTextNAValue(); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease (title); } // Print Selection title = CFCopyLocalizedStringFromTableInBundle( CFSTR("Print Selection"), CFSTR("Localizable"), MyGetBundle(), "Print Selection title (for summary)"); if (title != NULL) { if (context->settings.mHaveSelection) value = GetSummaryTextBooleanValue(context->settings.mPrintSelection); else value = GetSummaryTextNAValue(); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease (title); } // Shrink To Fit title = CFCopyLocalizedStringFromTableInBundle( CFSTR("Shrink To Fit"), CFSTR("Localizable"), MyGetBundle(), "Shrink To Fit title (for summary)"); if (title != NULL) { value = GetSummaryTextBooleanValue(context->settings.mShrinkToFit); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease (title); } // Print BG Colors title = CFCopyLocalizedStringFromTableInBundle( CFSTR("Print BG Colors"), CFSTR("Localizable"), MyGetBundle(), "Print BG Colors title (for summary)"); if (title != NULL) { value = GetSummaryTextBooleanValue(context->settings.mPrintBGColors); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease (title); } // Print BG Images title = CFCopyLocalizedStringFromTableInBundle( CFSTR("Print BG Images"), CFSTR("Localizable"), MyGetBundle(), "Print BG Images title (for summary)"); if (title != NULL) { value = GetSummaryTextBooleanValue(context->settings.mPrintBGImages); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease (title); } // Page Headers title = CFCopyLocalizedStringFromTableInBundle( CFSTR("Page Headers"), CFSTR("Localizable"), MyGetBundle(), "Page Headers (for summary)"); if (title != NULL) { format = CFCopyLocalizedStringFromTableInBundle( CFSTR("%@, %@, %@"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer format (for summary)"); if (format != NULL) { value = CFStringCreateWithFormat(NULL, NULL, format, GetSummaryTextHeaderFooterValue(context->settings.mHeaderLeft), GetSummaryTextHeaderFooterValue(context->settings.mHeaderCenter), GetSummaryTextHeaderFooterValue(context->settings.mHeaderRight)); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease(format); } CFRelease (title); } // Page Footers title = CFCopyLocalizedStringFromTableInBundle( CFSTR("Page Footers"), CFSTR("Localizable"), MyGetBundle(), "Page Footers (for summary)"); if (title != NULL) { format = CFCopyLocalizedStringFromTableInBundle( CFSTR("%@, %@, %@"), CFSTR("Localizable"), MyGetBundle(), "Page Heaader/Footer format (for summary)"); if (format != NULL) { value = CFStringCreateWithFormat(NULL, NULL, format, GetSummaryTextHeaderFooterValue(context->settings.mFooterLeft), GetSummaryTextHeaderFooterValue(context->settings.mFooterCenter), GetSummaryTextHeaderFooterValue(context->settings.mFooterRight)); if (value != NULL) { // append the title-value pair to the arrays CFArrayAppendValue (titleArray, title); CFArrayAppendValue (valueArray, value); CFRelease (value); } CFRelease(format); } CFRelease (title); } return result; }
void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, const Point & inLocation, const SInt16 inRightOffset, const SInt16 inTotalWidth) { #if !__LP64__ // get component info ComponentDescription desc; Handle h1 = NewHandleClear(4); OSStatus err = GetComponentInfo ((Component)auView->GetEditAudioUnit(), &desc, h1, 0, 0); if (err == noErr) { // Get the manufacturer's name... look for the ':' character convention HLock(h1); char* ptr1 = *h1; int len = *ptr1++; char* displayStr = 0; for (int i = 0; i < len; ++i) { if (ptr1[i] == ':') { // found the name ptr1[i++] = 0; displayStr = ptr1; break; } } // localize as necessary: if (!sLocalized) { CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); if (mainBundle) { kStringManufacturer = CFCopyLocalizedStringFromTableInBundle( kAUViewLocalizedStringKey_Manufacturer, kLocalizedStringTable_AUView, mainBundle, CFSTR("Manufacturer title string")); sLocalized = true; } } // display strings ControlRef newControl; Rect r; r.top = SInt16(inLocation.v); r.bottom = SInt16(inLocation.v) + 16; ControlFontStyleRec fontStyle; fontStyle.flags = kControlUseFontMask | kControlUseJustMask; fontStyle.font = kControlFontSmallBoldSystemFont; // display manufacturer string if (displayStr) { CFMutableStringRef mfrstring = CFStringCreateMutable(NULL, 0); CFStringAppend(mfrstring, kStringManufacturer); // "Manufacturer" CFStringAppend(mfrstring, kAUViewUnlocalizedString_TitleSeparator); // "Manufacturer: " CFStringRef mfrname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8); if (mfrname) { CFStringAppend(mfrstring, mfrname); // "Manufacturer: MFRName" CFRelease (mfrname); } r.left = inLocation.h + inRightOffset; r.right = inLocation.h + inTotalWidth - 28; fontStyle.just = teFlushRight; verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, mfrstring, &fontStyle, &newControl)); verify_noerr(auView->EmbedControl(newControl)); CFRelease (mfrstring); //move displayStr ptr past the manu, to the name // we move the characters down an index, because the handle doesn't have any room // at the end for the \0 int i = strlen(displayStr), j = 0; while (displayStr[++i] == ' ' && i < len) ; while (i < len) displayStr[j++] = displayStr[i++]; displayStr[j] = 0; } else { displayStr = ptr1; int i = 0, j = 0; do { displayStr[j] = displayStr[i]; ++j; ++i; } while (i < len); displayStr[j] = 0; } // display AudioUnit string r.left = inLocation.h; r.right = r.left + inRightOffset; fontStyle.just = 0; CFMutableStringRef cfstr = CFStringCreateMutable(NULL, 0); CFStringAppend(cfstr, kAUViewLocalizedStringKey_AudioUnit); // "Audio Unit" CFStringAppend(cfstr, kAUViewUnlocalizedString_TitleSeparator); // "Audio Unit: " CFStringRef auname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8); CFStringAppend(cfstr, auname); // "Audio Unit: AUName" CFRelease (auname); verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, cfstr, &fontStyle, &newControl)); // size text control correctly Boolean bValue = false; SetControlData(newControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue); SInt16 baseLineOffset; Rect bestRect; err = GetBestControlRect(newControl, &bestRect, &baseLineOffset); if (err == noErr) { int width = (bestRect.right - bestRect.left) + 1; int height = (bestRect.bottom - bestRect.top) + 1; SizeControl (newControl, width, height); } verify_noerr(auView->EmbedControl(newControl)); CFRelease (cfstr); } DisposeHandle (h1); #endif }
void ACAppleIMA4Encoder::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData) { switch(inPropertyID) { #if !BUILD_ADEC_LIB case kAudioCodecPropertyNameCFString: { if (ioPropertyDataSize != sizeof(CFStringRef)) { CODEC_THROW(kAudioCodecBadPropertySizeError); } CABundleLocker lock; CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Acme IMA4 encoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR("")); *(CFStringRef*)outPropertyData = name; break; } #endif case kAudioCodecPropertyAvailableNumberChannels: if(ioPropertyDataSize == sizeof(UInt32) * kMaxIMA4Channels) { memcpy(reinterpret_cast<UInt32*>(outPropertyData), mSupportedChannelTotals, ioPropertyDataSize); } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyAvailableInputSampleRates: if(ioPropertyDataSize == sizeof(AudioValueRange) ) { (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMinimum = 0.0; (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMaximum = 0.0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyAvailableOutputSampleRates: if(ioPropertyDataSize == sizeof(AudioValueRange) ) { (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMinimum = 0.0; (reinterpret_cast<AudioValueRange*>(outPropertyData))->mMaximum = 0.0; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyPrimeInfo: if(ioPropertyDataSize == sizeof(AudioCodecPrimeInfo) ) { (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->leadingFrames = 0; (reinterpret_cast<AudioCodecPrimeInfo*>(outPropertyData))->trailingFrames = mZeroesPadded; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; case kAudioCodecPropertyZeroFramesPadded: if(ioPropertyDataSize == sizeof(UInt32)) { *reinterpret_cast<UInt32*>(outPropertyData) = mZeroesPadded; } else { CODEC_THROW(kAudioCodecBadPropertySizeError); } break; default: ACAppleIMA4Codec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData); } }