Browse Source

AU: Support getting component description without a 'thng' resource in getComponentDescFromFile()

tags/2021-05-28
ed 6 years ago
parent
commit
4635e91603
1 changed files with 38 additions and 21 deletions
  1. +38
    -21
      modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm

+ 38
- 21
modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm View File

@@ -236,36 +236,53 @@ namespace AudioUnitFormatHelpers
UseResFile (resFileId);
const OSType thngType = stringToOSType ("thng");
auto numResources = Count1Resources (thngType);
for (ResourceIndex i = 1; i <= Count1Resources (thngType); ++i)
if (numResources > 0)
{
if (Handle h = Get1IndResource (thngType, i))
for (ResourceIndex i = 1; i <= numResources; ++i)
{
HLock (h);
const uint32* const types = (const uint32*) *h;
if (types[0] == kAudioUnitType_MusicDevice
|| types[0] == kAudioUnitType_MusicEffect
|| types[0] == kAudioUnitType_Effect
|| types[0] == kAudioUnitType_Generator
|| types[0] == kAudioUnitType_Panner
|| types[0] == kAudioUnitType_Mixer
|| types[0] == kAudioUnitType_MIDIProcessor)
if (Handle h = Get1IndResource (thngType, i))
{
desc.componentType = types[0];
desc.componentSubType = types[1];
desc.componentManufacturer = types[2];
HLock (h);
const uint32* const types = (const uint32*) *h;
if (types[0] == kAudioUnitType_MusicDevice
|| types[0] == kAudioUnitType_MusicEffect
|| types[0] == kAudioUnitType_Effect
|| types[0] == kAudioUnitType_Generator
|| types[0] == kAudioUnitType_Panner
|| types[0] == kAudioUnitType_Mixer
|| types[0] == kAudioUnitType_MIDIProcessor)
{
desc.componentType = types[0];
desc.componentSubType = types[1];
desc.componentManufacturer = types[2];
if (AudioComponent comp = AudioComponentFindNext (nullptr, &desc))
getNameAndManufacturer (comp, name, manufacturer);
if (AudioComponent comp = AudioComponentFindNext (nullptr, &desc))
getNameAndManufacturer (comp, name, manufacturer);
break;
}
break;
}
HUnlock (h);
ReleaseResource (h);
HUnlock (h);
ReleaseResource (h);
}
}
}
else
{
NSBundle* bundle = [[NSBundle alloc] initWithPath: (NSString*) fileOrIdentifier.toCFString()];
NSArray* audioComponents = [bundle objectForInfoDictionaryKey: @"AudioComponents"];
NSDictionary* dict = audioComponents[0];
desc.componentManufacturer = stringToOSType (nsStringToJuce ((NSString*) [dict valueForKey: @"manufacturer"]));
desc.componentType = stringToOSType (nsStringToJuce ((NSString*) [dict valueForKey: @"type"]));
desc.componentSubType = stringToOSType (nsStringToJuce ((NSString*) [dict valueForKey: @"subtype"]));
[bundle release];
}
CFBundleCloseBundleResourceMap (bundleRef, resFileId);
CFRelease (bundleRef);


Loading…
Cancel
Save