Update deprecated calls

This commit is contained in:
Matthias Neeracher 2011-09-03 22:34:53 +02:00
parent 5fa9b02909
commit 3567608c0c
6 changed files with 51 additions and 64 deletions

View File

@ -133,12 +133,12 @@
//
// Look for running copies of Lilypond first
//
NSArray * runningApps = [[NSWorkspace sharedWorkspace] launchedApplications];
for (NSDictionary * app in runningApps)
if ([[app objectForKey:@"NSApplicationBundleIdentifier"] isEqual:@"org.lilypond.lilypond"]
|| [[app objectForKey:@"NSApplicationName"] isEqual:@"LilyPond"]
NSArray * runningApps = [[NSWorkspace sharedWorkspace] runningApplications];
for (NSRunningApplication * app in runningApps)
if ([[app bundleIdentifier] isEqual:@"org.lilypond.lilypond"]
|| [[app localizedName] isEqual:@"LilyPond"]
)
if ((appPath = [[app objectForKey:@"NSApplicationPath"] stringByAppendingPathComponent:@"Contents/Resources/bin/lilypond"]))
if ((appPath = [[[app bundleURL] path] stringByAppendingPathComponent:@"Contents/Resources/bin/lilypond"]))
break;
if (!appPath)
appPath =

View File

@ -54,7 +54,7 @@ enum {
float chordPadding;
float lyricPadding;
int playElements;
NSString * tmpPath;
NSURL * tmpURL;
NSFileWrapper * vcsWrapper;
NSMutableArray* observers;
NSMutableDictionary*validTmpFiles;
@ -96,8 +96,8 @@ enum {
- (IBAction) adjustTempo:(id)sender;
- (IBAction) togglePlayElements:(id)sender;
- (NSString *) tmpPath;
- (NSString *) workPath;
- (NSURL *) tmpURL;
- (NSURL *) workURL;
- (NSString *) baseName;
- (NSURL *) fileURLWithExtension:(NSString*)extension;
- (void) createTmpFileWithExtension:(NSString*)ext ofType:(NSString*)type;

View File

@ -98,7 +98,7 @@
sheetWin = nil;
pdfWin = nil;
logWin = nil;
tmpPath = nil;
tmpURL = nil;
vcsWrapper = nil;
repeatVolta = 2;
brandNew = true;
@ -154,9 +154,9 @@
[undo release];
[observers release];
if (tmpPath) {
[[NSFileManager defaultManager] removeFileAtPath:tmpPath handler:nil];
[tmpPath release];
if (tmpURL) {
[[NSFileManager defaultManager] removeItemAtURL:tmpURL error:nil];
[tmpURL release];
}
[super dealloc];
@ -363,34 +363,33 @@
repeatVolta = volta;
}
- (NSString *) tmpPath
- (NSURL *) tmpURL
{
if (!tmpPath) {
tmpPath = [[NSString alloc] initWithFormat:@"/var/tmp/VocalEasel.%08x",
self];
[[NSFileManager defaultManager] createDirectoryAtPath:tmpPath attributes:nil];
if (!tmpURL) {
NSString * tmpPath = [NSString stringWithFormat:@"/var/tmp/VocalEasel.%08x", self];
tmpURL = [[NSURL alloc] initFileURLWithPath:tmpPath];
[[NSFileManager defaultManager] createDirectoryAtURL:tmpURL withIntermediateDirectories:NO attributes:nil error:nil];
}
return tmpPath;
return tmpURL;
}
- (NSString *) workPath
- (NSURL *) workURL
{
if ([self fileURL]) // Prefer our wrapper directory
return [[self fileURL] path];
if (NSURL * url = [self fileURL]) // Prefer our wrapper directory
return url;
else
return [self tmpPath];
return [self tmpURL];
}
- (NSString *) baseName
{
return [[[self workPath] lastPathComponent] stringByDeletingPathExtension];
return [[[self workURL] lastPathComponent] stringByDeletingPathExtension];
}
- (NSURL *) fileURLWithExtension:(NSString*)extension
{
return [NSURL fileURLWithPath:
[[[self workPath] stringByAppendingPathComponent:[self baseName]]
stringByAppendingPathExtension:extension]];
return [[[self workURL] URLByAppendingPathComponent:[self baseName]]
URLByAppendingPathExtension:extension];
}
- (BOOL)saveToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation error:(NSError **)outError
@ -478,13 +477,12 @@
- (void) changedFileWrapper
{
if (NSURL * url = [self fileURL])
if (NSDate * modDate =
[[[NSFileManager defaultManager] fileAttributesAtPath:[url path]
traverseLink:YES]
objectForKey:NSFileModificationDate])
if (NSURL * url = [self workURL]) {
NSDate * modDate;
if ([url getResourceValue:&modDate forKey:NSURLAttributeModificationDateKey error:nil])
[self setFileModificationDate:modDate];
}
}
- (void) createTmpFileWithExtension:(NSString*)ext ofType:(NSString*)type
{
@ -502,7 +500,7 @@
- (NSTask *) taskWithLaunchPath:(NSString *)launch arguments:(NSArray *)args;
{
NSTask * task = [[NSTask alloc] init];
NSString * path = [self workPath];
NSString * path = [[self workURL] path];
NSPipe * pipe = [NSPipe pipe];
[task setCurrentDirectoryPath: path];
@ -528,11 +526,8 @@
MusicSequence music;
NewMusicSequence(&music);
FSRef fsRef;
CFURLGetFSRef((CFURLRef)[self fileURLWithExtension:@"mid"], &fsRef);
MusicSequenceLoadSMFWithFlags(music, &fsRef,
kMusicSequenceLoadSMF_ChannelsToTracks);
MusicSequenceFileLoad(music, (CFURLRef)[self fileURLWithExtension:@"mid"],
0, kMusicSequenceLoadSMF_ChannelsToTracks);
size_t countIn = 0;
if (playElements & kVLPlayCountIn)
@ -598,7 +593,7 @@
- (IBAction) playMusic:(id)sender
{
switch (int tag = [sender tag]) {
switch ([sender tag]) {
case 1: // Fwd
VLSoundOut::Instance()->Fwd();
break;

View File

@ -6,11 +6,11 @@
//
// (MN) Matthias Neeracher
//
// Copyright © 2007 Matthias Neeracher
// Copyright © 2007-2011 Matthias Neeracher
//
#import "VLKeyValueUndo.h"
#import "VLDocument.h"
@implementation VLKeyValueUndo

View File

@ -36,9 +36,9 @@
VLDocument *doc = [self document];
NSURL * pdfURL = [doc fileURLWithExtension:@"pdf"];
if (!pdfURL) {
NSString * path = [doc workPath];
NSURL * workURL = [doc workURL];
NSFileWrapper * wrapper =
[[[NSFileWrapper alloc] initWithPath:path] autorelease];
[[[NSFileWrapper alloc] initWithURL:workURL options:0 error:nil] autorelease];
//
// Find newest pdf file
//
@ -57,9 +57,7 @@
}
}
if (pdfPath)
pdfURL =
[NSURL fileURLWithPath:
[path stringByAppendingPathComponent:pdfPath]];
pdfURL = [workURL URLByAppendingPathComponent:pdfPath];
}
if (pdfURL) {
PDFDocument * pdfDoc =

View File

@ -106,7 +106,7 @@ void VLSoundOut::PlayFile(CFDataRef file)
MusicSequence music;
NewMusicSequence(&music);
MusicSequenceLoadSMFDataWithFlags(music, file,
MusicSequenceFileLoadData(music, file, 0,
kMusicSequenceLoadSMF_ChannelsToTracks);
PlaySequence(music);
}
@ -136,7 +136,7 @@ VLAUSoundOut::~VLAUSoundOut()
void VLAUSoundOut::InitSoundOutput(bool fileOutput)
{
AUNode synthNode, limiterNode, outNode;
ComponentDescription cd;
AudioComponentDescription cd;
cd.componentManufacturer = kAudioUnitManufacturer_Apple;
cd.componentFlags = 0;
@ -147,12 +147,12 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
cd.componentType = kAudioUnitType_MusicDevice;
cd.componentSubType = kAudioUnitSubType_DLSSynth;
AUGraphNewNode(fGraph, &cd, 0, NULL, &synthNode);
AUGraphAddNode(fGraph, &cd, &synthNode);
cd.componentType = kAudioUnitType_Effect;
cd.componentSubType = kAudioUnitSubType_PeakLimiter;
AUGraphNewNode (fGraph, &cd, 0, NULL, &limiterNode);
AUGraphAddNode (fGraph, &cd, &limiterNode);
cd.componentType = kAudioUnitType_Output;
if (fileOutput)
@ -160,7 +160,7 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
else
cd.componentSubType = kAudioUnitSubType_DefaultOutput;
AUGraphNewNode(fGraph, &cd, 0, NULL, &outNode);
AUGraphAddNode(fGraph, &cd, &outNode);
R(AUGraphOpen(fGraph));
AUGraphConnectNodeInput(fGraph, synthNode, 0, limiterNode, 0);
@ -169,7 +169,7 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
if (fileOutput) {
UInt32 value = 1;
AudioUnit synth;
R(AUGraphGetNodeInfo(fGraph, synthNode, 0, 0, 0, &synth));
R(AUGraphNodeInfo(fGraph, synthNode, NULL, &synth));
R(AudioUnitSetProperty(synth,
kAudioUnitProperty_OfflineRender,
kAudioUnitScope_Global, 0,
@ -349,7 +349,7 @@ VLAUFileSoundOut::~VLAUFileSoundOut()
void VLAUFileSoundOut::SetupOutput(AUNode outputNode)
{
R(AUGraphGetNodeInfo(fGraph, outputNode, 0, 0, 0, &fOutput));
R(AUGraphNodeInfo(fGraph, outputNode, NULL, &fOutput));
Float64 sampleRate = 22050.0;
R(AudioUnitSetProperty(fOutput,
kAudioUnitProperty_SampleRate,
@ -405,17 +405,11 @@ void VLAUFileSoundOut::PlaySequence(MusicSequence music)
R(AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL,
&size, &outputFormat));
}
CFURLRef dir =
CFURLCreateCopyDeletingLastPathComponent(NULL, fFile);
FSRef parentDir;
CFURLGetFSRef(dir, &parentDir);
CFRelease(dir);
CFRelease(name);
ExtAudioFileRef outfile;
R(ExtAudioFileCreateNew(&parentDir, name,
fileType, &outputFormat, NULL, &outfile));
CFRelease(name);
R(ExtAudioFileCreateWithURL(fFile, fileType, &outputFormat, NULL,
kAudioFileFlags_EraseFile, &outfile));
CAStreamBasicDescription clientFormat;
size = sizeof(clientFormat);