mirror of
https://github.com/holub/mame
synced 2025-07-01 08:18:59 +03:00
make the C-like parts more consistent with MAME (nw)
This commit is contained in:
parent
8c002c645c
commit
f8d7be5164
@ -55,11 +55,12 @@ static NSString *const ForceGenericViewKey = @"ForceGenericView";
|
|||||||
static NSString *const WindowFrameKey = @"WindowFrame";
|
static NSString *const WindowFrameKey = @"WindowFrame";
|
||||||
|
|
||||||
|
|
||||||
static void UpdateChangeCountCallback(void *userData,
|
static void UpdateChangeCountCallback(
|
||||||
void *object,
|
void *userData,
|
||||||
AudioUnitEvent const *inEvent,
|
void *object,
|
||||||
UInt64 inEventHostTime,
|
AudioUnitEvent const *inEvent,
|
||||||
AudioUnitParameterValue inParameterValue)
|
UInt64 inEventHostTime,
|
||||||
|
AudioUnitParameterValue inParameterValue)
|
||||||
{
|
{
|
||||||
[(NSDocument *)userData updateChangeCount:NSChangeDone];
|
[(NSDocument *)userData updateChangeCount:NSChangeDone];
|
||||||
}
|
}
|
||||||
@ -99,19 +100,20 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
@implementation AUEffectDocument
|
@implementation AUEffectDocument
|
||||||
|
|
||||||
- (void)loadEffectUI {
|
- (void)loadEffectUI {
|
||||||
if ((0 == effectNode) || (nil == window))
|
if ((0 == effectNode) || !window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOOL customViewValid = NO;
|
BOOL customViewValid = NO;
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
UInt32 uiDescSize;
|
UInt32 uiDescSize;
|
||||||
AudioUnitCocoaViewInfo *viewInfo;
|
AudioUnitCocoaViewInfo *viewInfo;
|
||||||
status = AudioUnitGetPropertyInfo(effectUnit,
|
status = AudioUnitGetPropertyInfo(
|
||||||
kAudioUnitProperty_CocoaUI,
|
effectUnit,
|
||||||
kAudioUnitScope_Global,
|
kAudioUnitProperty_CocoaUI,
|
||||||
0,
|
kAudioUnitScope_Global,
|
||||||
&uiDescSize,
|
0,
|
||||||
NULL);
|
&uiDescSize,
|
||||||
|
NULL);
|
||||||
UInt32 const uiClassCount = 1 + ((uiDescSize - sizeof(*viewInfo)) / sizeof(viewInfo->mCocoaAUViewClass[0]));
|
UInt32 const uiClassCount = 1 + ((uiDescSize - sizeof(*viewInfo)) / sizeof(viewInfo->mCocoaAUViewClass[0]));
|
||||||
if ((noErr == status) && (0 < uiClassCount))
|
if ((noErr == status) && (0 < uiClassCount))
|
||||||
{
|
{
|
||||||
@ -126,7 +128,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
{
|
{
|
||||||
NSBundle *const bundle = [NSBundle bundleWithPath:[(NSURL *)viewInfo->mCocoaAUViewBundleLocation path]];
|
NSBundle *const bundle = [NSBundle bundleWithPath:[(NSURL *)viewInfo->mCocoaAUViewBundleLocation path]];
|
||||||
Class const viewClass = [bundle classNamed:(NSString *)viewInfo->mCocoaAUViewClass[0]];
|
Class const viewClass = [bundle classNamed:(NSString *)viewInfo->mCocoaAUViewClass[0]];
|
||||||
if ((NULL != viewClass)
|
if (viewClass
|
||||||
&& [viewClass conformsToProtocol:@protocol(AUCocoaUIBase)]
|
&& [viewClass conformsToProtocol:@protocol(AUCocoaUIBase)]
|
||||||
&& [viewClass instancesRespondToSelector:@selector(uiViewForAudioUnit:withSize:)])
|
&& [viewClass instancesRespondToSelector:@selector(uiViewForAudioUnit:withSize:)])
|
||||||
{
|
{
|
||||||
@ -145,7 +147,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
free(viewInfo);
|
free(viewInfo);
|
||||||
}
|
}
|
||||||
if (nil == view)
|
if (!view)
|
||||||
{
|
{
|
||||||
view = [[[AUGenericView alloc] initWithAudioUnit:effectUnit] autorelease];
|
view = [[[AUGenericView alloc] initWithAudioUnit:effectUnit] autorelease];
|
||||||
[(AUGenericView *)view setShowsExpertParameters:YES];
|
[(AUGenericView *)view setShowsExpertParameters:YES];
|
||||||
@ -190,7 +192,8 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
if (!(self = [super init])) return nil;
|
if (!(self = [super init]))
|
||||||
|
return nil;
|
||||||
|
|
||||||
window = nil;
|
window = nil;
|
||||||
genericViewButton = nil;
|
genericViewButton = nil;
|
||||||
@ -232,16 +235,16 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
if (NULL != presets)
|
if (presets)
|
||||||
CFRelease(presets);
|
CFRelease(presets);
|
||||||
|
|
||||||
if (NULL != listener)
|
if (listener)
|
||||||
AUListenerDispose(listener);
|
AUListenerDispose(listener);
|
||||||
|
|
||||||
if (nil != restoreFrame)
|
if (restoreFrame)
|
||||||
[restoreFrame release];
|
[restoreFrame release];
|
||||||
|
|
||||||
if (NULL != graph)
|
if (graph)
|
||||||
{
|
{
|
||||||
AUGraphClose(graph);
|
AUGraphClose(graph);
|
||||||
DisposeAUGraph(graph);
|
DisposeAUGraph(graph);
|
||||||
@ -272,14 +275,16 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
[presetButton sizeToFit];
|
[presetButton sizeToFit];
|
||||||
|
|
||||||
CGFloat const controlWidth = MAX(NSWidth([genericViewButton frame]), NSWidth([presetButton frame]));
|
CGFloat const controlWidth = MAX(NSWidth([genericViewButton frame]), NSWidth([presetButton frame]));
|
||||||
NSRect const presetFrame = NSMakeRect(17,
|
NSRect const presetFrame = NSMakeRect(
|
||||||
8,
|
17,
|
||||||
controlWidth,
|
8,
|
||||||
NSHeight([presetButton frame]));
|
controlWidth,
|
||||||
NSRect const genericViewFrame = NSMakeRect(17,
|
NSHeight([presetButton frame]));
|
||||||
NSMaxY(presetFrame) + 9,
|
NSRect const genericViewFrame = NSMakeRect(
|
||||||
controlWidth,
|
17,
|
||||||
NSHeight([genericViewButton frame]));
|
NSMaxY(presetFrame) + 9,
|
||||||
|
controlWidth,
|
||||||
|
NSHeight([genericViewButton frame]));
|
||||||
[genericViewButton setFrame:genericViewFrame];
|
[genericViewButton setFrame:genericViewFrame];
|
||||||
[presetButton setFrame:presetFrame];
|
[presetButton setFrame:presetFrame];
|
||||||
|
|
||||||
@ -310,7 +315,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
[window release];
|
[window release];
|
||||||
|
|
||||||
[self loadEffectUI];
|
[self loadEffectUI];
|
||||||
if (nil != restoreFrame)
|
if (restoreFrame)
|
||||||
{
|
{
|
||||||
[window setFrameFromString:restoreFrame];
|
[window setFrameFromString:restoreFrame];
|
||||||
}
|
}
|
||||||
@ -331,7 +336,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
BOOL const hasWrapper = [type isEqualToString:AUEffectDocumentType];
|
BOOL const hasWrapper = [type isEqualToString:AUEffectDocumentType];
|
||||||
if (!hasWrapper && ![type isEqualToString:AUPresetDocumentType])
|
if (!hasWrapper && ![type isEqualToString:AUPresetDocumentType])
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString *const message = [NSString stringWithFormat:@"Unsupported document type %@", type];
|
NSString *const message = [NSString stringWithFormat:@"Unsupported document type %@", type];
|
||||||
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:message, NSLocalizedDescriptionKey,
|
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:message, NSLocalizedDescriptionKey,
|
||||||
@ -346,16 +351,16 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
mutabilityOption:0
|
mutabilityOption:0
|
||||||
format:NULL
|
format:NULL
|
||||||
errorDescription:&errDesc];
|
errorDescription:&errDesc];
|
||||||
if ((nil == desc) || ![desc isKindOfClass:[NSDictionary class]] || (nil != errDesc))
|
if (!desc || ![desc isKindOfClass:[NSDictionary class]] || errDesc)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString *const message = [NSString stringWithFormat:@"Error in file format (%@)", errDesc];
|
NSString *const message = [NSString stringWithFormat:@"Error in file format (%@)", errDesc];
|
||||||
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:message, NSLocalizedDescriptionKey,
|
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:message, NSLocalizedDescriptionKey,
|
||||||
nil];
|
nil];
|
||||||
*error = [NSError errorWithDomain:AUEffectUtilErrorDomain code:0 userInfo:info];
|
*error = [NSError errorWithDomain:AUEffectUtilErrorDomain code:0 userInfo:info];
|
||||||
}
|
}
|
||||||
if (nil != errDesc)
|
if (errDesc)
|
||||||
[errDesc release];
|
[errDesc release];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@ -363,12 +368,12 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
id const typeValue = [desc objectForKey:(hasWrapper ? ComponentTypeKey : (NSString *)CFSTR(kAUPresetTypeKey))];
|
id const typeValue = [desc objectForKey:(hasWrapper ? ComponentTypeKey : (NSString *)CFSTR(kAUPresetTypeKey))];
|
||||||
id const subtypeValue = [desc objectForKey:(hasWrapper ? ComponentSubTypeKey : (NSString *)CFSTR(kAUPresetSubtypeKey))];
|
id const subtypeValue = [desc objectForKey:(hasWrapper ? ComponentSubTypeKey : (NSString *)CFSTR(kAUPresetSubtypeKey))];
|
||||||
id const manufacturerValue = [desc objectForKey:(hasWrapper ? ComponentManufacturerKey : (NSString *)CFSTR(kAUPresetManufacturerKey))];
|
id const manufacturerValue = [desc objectForKey:(hasWrapper ? ComponentManufacturerKey : (NSString *)CFSTR(kAUPresetManufacturerKey))];
|
||||||
if ((nil == typeValue) || ![typeValue isKindOfClass:[NSNumber class]]
|
if (!typeValue || ![typeValue isKindOfClass:[NSNumber class]]
|
||||||
|| (nil == subtypeValue) || ![subtypeValue isKindOfClass:[NSNumber class]]
|
|| !subtypeValue || ![subtypeValue isKindOfClass:[NSNumber class]]
|
||||||
|| (nil == manufacturerValue) || ![manufacturerValue isKindOfClass:[NSNumber class]]
|
|| !manufacturerValue || ![manufacturerValue isKindOfClass:[NSNumber class]]
|
||||||
|| ([typeValue unsignedLongValue] != kAudioUnitType_Effect))
|
|| ([typeValue unsignedLongValue] != kAudioUnitType_Effect))
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString *const message = @"Error in effect description file format";
|
NSString *const message = @"Error in effect description file format";
|
||||||
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:message, NSLocalizedDescriptionKey,
|
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:message, NSLocalizedDescriptionKey,
|
||||||
@ -378,17 +383,17 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != presets)
|
if (presets)
|
||||||
{
|
{
|
||||||
CFRelease(presets);
|
CFRelease(presets);
|
||||||
presets = NULL;
|
presets = NULL;
|
||||||
}
|
}
|
||||||
if (NULL != listener)
|
if (listener)
|
||||||
{
|
{
|
||||||
AUListenerDispose(listener);
|
AUListenerDispose(listener);
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
}
|
}
|
||||||
if (nil != view)
|
if (view)
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
name:NSViewFrameDidChangeNotification
|
name:NSViewFrameDidChangeNotification
|
||||||
@ -408,14 +413,19 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
description.componentManufacturer = [manufacturerValue longValue];
|
description.componentManufacturer = [manufacturerValue longValue];
|
||||||
status = noErr;
|
status = noErr;
|
||||||
status = AUGraphClearConnections(graph);
|
status = AUGraphClearConnections(graph);
|
||||||
if (noErr == status) status = AUGraphAddNode(graph, &description, &effectNode);
|
if (noErr == status)
|
||||||
if (noErr == status) status = AUGraphNodeInfo(graph, effectNode, NULL, &effectUnit);
|
status = AUGraphAddNode(graph, &description, &effectNode);
|
||||||
if (noErr == status) status = AUGraphConnectNodeInput(graph, sourceNode, 0, effectNode, 0);
|
if (noErr == status)
|
||||||
if (noErr == status) status = AUGraphConnectNodeInput(graph, effectNode, 0, outputNode, 0);
|
status = AUGraphNodeInfo(graph, effectNode, NULL, &effectUnit);
|
||||||
if (noErr == status) status = AUGraphUpdate(graph, NULL);
|
if (noErr == status)
|
||||||
|
status = AUGraphConnectNodeInput(graph, sourceNode, 0, effectNode, 0);
|
||||||
|
if (noErr == status)
|
||||||
|
status = AUGraphConnectNodeInput(graph, effectNode, 0, outputNode, 0);
|
||||||
|
if (noErr == status)
|
||||||
|
status = AUGraphUpdate(graph, NULL);
|
||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString * const message = @"Error encountered while configuring AudioUnit graph";
|
NSString * const message = @"Error encountered while configuring AudioUnit graph";
|
||||||
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||||
@ -428,19 +438,21 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFPropertyListRef const classInfo = (CFPropertyListRef)(hasWrapper ? [desc objectForKey:ClassInfoKey] : desc);
|
CFPropertyListRef const classInfo = (CFPropertyListRef)(hasWrapper ? [desc objectForKey:ClassInfoKey] : desc);
|
||||||
if (NULL != classInfo)
|
if (classInfo)
|
||||||
{
|
{
|
||||||
AudioUnitParameter change = { effectUnit, kAUParameterListener_AnyParameter, 0, 0 };
|
AudioUnitParameter change = { effectUnit, kAUParameterListener_AnyParameter, 0, 0 };
|
||||||
status = AudioUnitSetProperty(effectUnit,
|
status = AudioUnitSetProperty(
|
||||||
kAudioUnitProperty_ClassInfo,
|
effectUnit,
|
||||||
kAudioUnitScope_Global,
|
kAudioUnitProperty_ClassInfo,
|
||||||
0,
|
kAudioUnitScope_Global,
|
||||||
&classInfo,
|
0,
|
||||||
sizeof(classInfo));
|
&classInfo,
|
||||||
if (noErr == status) status = AUParameterListenerNotify(NULL, NULL, &change);
|
sizeof(classInfo));
|
||||||
|
if (noErr == status)
|
||||||
|
status = AUParameterListenerNotify(NULL, NULL, &change);
|
||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString * const message = @"Error configuring effect";
|
NSString * const message = @"Error configuring effect";
|
||||||
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||||
@ -463,7 +475,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
NULL);
|
NULL);
|
||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString * const message = @"Error getting effect parameters";
|
NSString * const message = @"Error getting effect parameters";
|
||||||
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||||
@ -477,16 +489,17 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
UInt32 const paramCount = propertySize / sizeof(AudioUnitParameterID);
|
UInt32 const paramCount = propertySize / sizeof(AudioUnitParameterID);
|
||||||
if (0U < paramCount)
|
if (0U < paramCount)
|
||||||
{
|
{
|
||||||
status = AUEventListenerCreate(UpdateChangeCountCallback,
|
status = AUEventListenerCreate(
|
||||||
self,
|
UpdateChangeCountCallback,
|
||||||
CFRunLoopGetCurrent(),
|
self,
|
||||||
kCFRunLoopDefaultMode,
|
CFRunLoopGetCurrent(),
|
||||||
0.05,
|
kCFRunLoopDefaultMode,
|
||||||
0.05,
|
0.05,
|
||||||
&listener);
|
0.05,
|
||||||
|
&listener);
|
||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString * const message = @"Error creating AudioUnit event listener";
|
NSString * const message = @"Error creating AudioUnit event listener";
|
||||||
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||||
@ -508,7 +521,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
free(params);
|
free(params);
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString * const message = @"Error getting effect parameters";
|
NSString * const message = @"Error getting effect parameters";
|
||||||
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||||
@ -533,7 +546,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
free(params);
|
free(params);
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString * const message = @"Error getting effect parameters";
|
NSString * const message = @"Error getting effect parameters";
|
||||||
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
NSError *const underlying = [NSError errorWithDomain:NSOSStatusErrorDomain code:status userInfo:nil];
|
||||||
@ -547,13 +560,14 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
propertySize = sizeof(presets);
|
propertySize = sizeof(presets);
|
||||||
status = AudioUnitGetProperty(effectUnit,
|
status = AudioUnitGetProperty(
|
||||||
kAudioUnitProperty_FactoryPresets,
|
effectUnit,
|
||||||
kAudioUnitScope_Global,
|
kAudioUnitProperty_FactoryPresets,
|
||||||
0,
|
kAudioUnitScope_Global,
|
||||||
&presets,
|
0,
|
||||||
&propertySize);
|
&presets,
|
||||||
if ((noErr != status) && (NULL != presets))
|
&propertySize);
|
||||||
|
if ((noErr != status) && presets)
|
||||||
{
|
{
|
||||||
CFRelease(presets);
|
CFRelease(presets);
|
||||||
presets = NULL;
|
presets = NULL;
|
||||||
@ -561,16 +575,17 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
|
|
||||||
if (hasWrapper)
|
if (hasWrapper)
|
||||||
{
|
{
|
||||||
if ((nil != [desc objectForKey:ForceGenericViewKey])
|
if ([desc objectForKey:ForceGenericViewKey]
|
||||||
&& [[desc objectForKey:ForceGenericViewKey] respondsToSelector:@selector(boolValue)])
|
&& [[desc objectForKey:ForceGenericViewKey] respondsToSelector:@selector(boolValue)])
|
||||||
{
|
{
|
||||||
forceGenericView = [[desc objectForKey:ForceGenericViewKey] boolValue];
|
forceGenericView = [[desc objectForKey:ForceGenericViewKey] boolValue];
|
||||||
[genericViewButton setState:(forceGenericView ? NSOnState : NSOffState)];
|
[genericViewButton setState:(forceGenericView ? NSOnState : NSOffState)];
|
||||||
}
|
}
|
||||||
if ((nil != [desc objectForKey:WindowFrameKey])
|
if ([desc objectForKey:WindowFrameKey]
|
||||||
&& [[desc objectForKey:WindowFrameKey] isKindOfClass:[NSString class]])
|
&& [[desc objectForKey:WindowFrameKey] isKindOfClass:[NSString class]])
|
||||||
{
|
{
|
||||||
if (nil != restoreFrame) [restoreFrame release];
|
if (restoreFrame)
|
||||||
|
[restoreFrame release];
|
||||||
restoreFrame = [[NSString alloc] initWithString:[desc objectForKey:WindowFrameKey]];
|
restoreFrame = [[NSString alloc] initWithString:[desc objectForKey:WindowFrameKey]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -583,12 +598,13 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
- (NSData *)dataOfType:(NSString *)type error:(NSError **)error {
|
- (NSData *)dataOfType:(NSString *)type error:(NSError **)error {
|
||||||
CFPropertyListRef classInfo;
|
CFPropertyListRef classInfo;
|
||||||
UInt32 infoSize = sizeof(classInfo);
|
UInt32 infoSize = sizeof(classInfo);
|
||||||
OSStatus const status = AudioUnitGetProperty(effectUnit,
|
OSStatus const status = AudioUnitGetProperty(
|
||||||
kAudioUnitProperty_ClassInfo,
|
effectUnit,
|
||||||
kAudioUnitScope_Global,
|
kAudioUnitProperty_ClassInfo,
|
||||||
0,
|
kAudioUnitScope_Global,
|
||||||
&classInfo,
|
0,
|
||||||
&infoSize);
|
&classInfo,
|
||||||
|
&infoSize);
|
||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (NULL != error)
|
||||||
@ -623,11 +639,11 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
desc = [NSDictionary dictionaryWithDictionary:(NSDictionary *)classInfo];
|
desc = [NSDictionary dictionaryWithDictionary:(NSDictionary *)classInfo];
|
||||||
}
|
}
|
||||||
CFRelease(classInfo);
|
CFRelease(classInfo);
|
||||||
if (nil == desc)
|
if (!desc)
|
||||||
{
|
{
|
||||||
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:@"Unsupported document type", NSLocalizedDescriptionKey,
|
NSDictionary *const info = [NSDictionary dictionaryWithObjectsAndKeys:@"Unsupported document type", NSLocalizedDescriptionKey,
|
||||||
nil];
|
nil];
|
||||||
*error = [NSError errorWithDomain:AUEffectUtilErrorDomain code:0 userInfo:info];
|
*error = [NSError errorWithDomain:AUEffectUtilErrorDomain code:0 userInfo:info];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,12 +651,12 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
NSData *const data = [NSPropertyListSerialization dataFromPropertyList:desc
|
NSData *const data = [NSPropertyListSerialization dataFromPropertyList:desc
|
||||||
format:NSPropertyListXMLFormat_v1_0
|
format:NSPropertyListXMLFormat_v1_0
|
||||||
errorDescription:&errDesc];
|
errorDescription:&errDesc];
|
||||||
if ((nil == data) || (nil != errDesc))
|
if (!data || errDesc)
|
||||||
{
|
{
|
||||||
if (NULL != error)
|
if (error)
|
||||||
{
|
{
|
||||||
NSString *message;
|
NSString *message;
|
||||||
if (nil != errDesc)
|
if (errDesc)
|
||||||
message = [NSString stringWithFormat:@"Error serialising effect settings: %@", errDesc];
|
message = [NSString stringWithFormat:@"Error serialising effect settings: %@", errDesc];
|
||||||
else
|
else
|
||||||
message = @"Error serialising effect settings";
|
message = @"Error serialising effect settings";
|
||||||
@ -648,7 +664,8 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
nil];
|
nil];
|
||||||
*error = [NSError errorWithDomain:AUEffectUtilErrorDomain code:0 userInfo:info];
|
*error = [NSError errorWithDomain:AUEffectUtilErrorDomain code:0 userInfo:info];
|
||||||
}
|
}
|
||||||
if (nil != errDesc) [errDesc release];
|
if (errDesc)
|
||||||
|
[errDesc release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
@ -656,7 +673,7 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
|
|
||||||
- (IBAction)toggleGenericView:(id)sender {
|
- (IBAction)toggleGenericView:(id)sender {
|
||||||
forceGenericView = (NSOnState == [sender state]);
|
forceGenericView = (NSOnState == [sender state]);
|
||||||
if (nil != view)
|
if (view)
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
name:NSViewFrameDidChangeNotification
|
name:NSViewFrameDidChangeNotification
|
||||||
@ -685,12 +702,13 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AUPreset const *preset = (AUPreset const *)CFArrayGetValueAtIndex(presets, idx);
|
AUPreset const *preset = (AUPreset const *)CFArrayGetValueAtIndex(presets, idx);
|
||||||
status = AudioUnitSetProperty(effectUnit,
|
status = AudioUnitSetProperty(
|
||||||
kAudioUnitProperty_PresentPreset,
|
effectUnit,
|
||||||
kAudioUnitScope_Global,
|
kAudioUnitProperty_PresentPreset,
|
||||||
0,
|
kAudioUnitScope_Global,
|
||||||
preset,
|
0,
|
||||||
sizeof(AUPreset));
|
preset,
|
||||||
|
sizeof(AUPreset));
|
||||||
if (noErr != status)
|
if (noErr != status)
|
||||||
{
|
{
|
||||||
NSAlert const *alert = [[NSAlert alloc] init];
|
NSAlert const *alert = [[NSAlert alloc] init];
|
||||||
@ -718,10 +736,11 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
- (void)viewFrameDidChange:(NSNotification *)notification {
|
- (void)viewFrameDidChange:(NSNotification *)notification {
|
||||||
NSRect const oldFrame = [window frame];
|
NSRect const oldFrame = [window frame];
|
||||||
NSRect const desired = [window frameRectForContentRect:[[notification object] frame]];
|
NSRect const desired = [window frameRectForContentRect:[[notification object] frame]];
|
||||||
NSRect const newFrame = NSMakeRect(oldFrame.origin.x,
|
NSRect const newFrame = NSMakeRect(
|
||||||
oldFrame.origin.y + oldFrame.size.height - headerSize.height- desired.size.height,
|
oldFrame.origin.x,
|
||||||
desired.size.width,
|
oldFrame.origin.y + oldFrame.size.height - headerSize.height- desired.size.height,
|
||||||
headerSize.height + desired.size.height);
|
desired.size.width,
|
||||||
|
headerSize.height + desired.size.height);
|
||||||
[window setFrame:newFrame display:YES animate:NO];
|
[window setFrame:newFrame display:YES animate:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,10 +838,10 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
|
|
||||||
[menu addItem:[NSMenuItem separatorItem]];
|
[menu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
item = [menu addItemWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"];
|
item = [menu addItemWithTitle:@"Cut" action:@selector(cut:) keyEquivalent:@"x"];
|
||||||
item = [menu addItemWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"];
|
item = [menu addItemWithTitle:@"Copy" action:@selector(copy:) keyEquivalent:@"c"];
|
||||||
item = [menu addItemWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"];
|
item = [menu addItemWithTitle:@"Paste" action:@selector(paste:) keyEquivalent:@"v"];
|
||||||
item = [menu addItemWithTitle:@"Delete" action:@selector(delete:) keyEquivalent:@""];
|
item = [menu addItemWithTitle:@"Delete" action:@selector(delete:) keyEquivalent:@""];
|
||||||
item = [menu addItemWithTitle:@"Select All" action:@selector(selectAll:) keyEquivalent:@"a"];
|
item = [menu addItemWithTitle:@"Select All" action:@selector(selectAll:) keyEquivalent:@"a"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,13 +878,15 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
if (!(self = [super init])) return nil;
|
if (!(self = [super init]))
|
||||||
|
return nil;
|
||||||
effects = NULL;
|
effects = NULL;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
if (effects) free(effects);
|
if (effects)
|
||||||
|
free(effects);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,12 +914,13 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
NSData *const data = [NSPropertyListSerialization dataFromPropertyList:desc
|
NSData *const data = [NSPropertyListSerialization dataFromPropertyList:desc
|
||||||
format:NSPropertyListXMLFormat_v1_0
|
format:NSPropertyListXMLFormat_v1_0
|
||||||
errorDescription:&errDesc];
|
errorDescription:&errDesc];
|
||||||
if ((nil == data) || (nil != errDesc))
|
if (!data || errDesc)
|
||||||
{
|
{
|
||||||
NSAlert *const alert = [[NSAlert alloc] init];
|
NSAlert *const alert = [[NSAlert alloc] init];
|
||||||
[alert setAlertStyle:NSWarningAlertStyle];
|
[alert setAlertStyle:NSWarningAlertStyle];
|
||||||
[alert setMessageText:@"Error serialising properties for new effect"];
|
[alert setMessageText:@"Error serialising properties for new effect"];
|
||||||
if (nil != errDesc) [alert setInformativeText:[errDesc autorelease]];
|
if (errDesc)
|
||||||
|
[alert setInformativeText:[errDesc autorelease]];
|
||||||
[alert addButtonWithTitle:@"OK"];
|
[alert addButtonWithTitle:@"OK"];
|
||||||
[alert runModal];
|
[alert runModal];
|
||||||
[alert release];
|
[alert release];
|
||||||
@ -907,10 +929,10 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
|
|
||||||
NSError *err = nil;
|
NSError *err = nil;
|
||||||
AUEffectDocument *const document = [[AUEffectDocument alloc] init];
|
AUEffectDocument *const document = [[AUEffectDocument alloc] init];
|
||||||
if ((nil == document) || ![document readFromData:data ofType:AUEffectDocumentType error:&err])
|
if (!document || ![document readFromData:data ofType:AUEffectDocumentType error:&err])
|
||||||
{
|
{
|
||||||
[document release];
|
[document release];
|
||||||
if (nil != err)
|
if (err)
|
||||||
{
|
{
|
||||||
[[NSAlert alertWithError:err] runModal];
|
[[NSAlert alertWithError:err] runModal];
|
||||||
}
|
}
|
||||||
@ -983,9 +1005,10 @@ static void UpdateChangeCountCallback(void *userData,
|
|||||||
effects[i].subtype = effectDesc.componentSubType;
|
effects[i].subtype = effectDesc.componentSubType;
|
||||||
effects[i].manufacturer = effectDesc.componentManufacturer;
|
effects[i].manufacturer = effectDesc.componentManufacturer;
|
||||||
HLock(nameHandle);
|
HLock(nameHandle);
|
||||||
CFStringRef name = CFStringCreateWithPascalString(NULL,
|
CFStringRef const name = CFStringCreateWithPascalString(
|
||||||
(unsigned char const *)*nameHandle,
|
NULL,
|
||||||
kCFStringEncodingMacRoman);
|
(unsigned char const *)*nameHandle,
|
||||||
|
kCFStringEncodingMacRoman);
|
||||||
HUnlock(nameHandle);
|
HUnlock(nameHandle);
|
||||||
NSMenuItem *const item = [newEffectMenu addItemWithTitle:(NSString *)name
|
NSMenuItem *const item = [newEffectMenu addItemWithTitle:(NSString *)name
|
||||||
action:@selector(newEffect:)
|
action:@selector(newEffect:)
|
||||||
|
Loading…
Reference in New Issue
Block a user