Updated everything else to ARC, and plugged a release cycle.

CQTexperiment
Chris Moeller 2016-05-05 13:05:39 -07:00
parent 80aa1b7e25
commit 0e3644177e
751 changed files with 72137 additions and 6104 deletions

View File

@ -1,11 +1,12 @@
#import "AppController.h"
#import "FileTreeController.h"
#import "FileTreeViewController.h"
#import "FileTreeOutlineView.h"
#import "PlaybackController.h"
#import "PlaylistController.h"
#import "PlaylistView.h"
#import "PlaylistEntry.h"
#import <NDHotKey/NDHotKeyEvent.h>
#import "AppleRemote.h"
#import "PlaylistLoader.h"
#import "OpenURLPanel.h"
#import "SpotlightWindowController.h"
@ -23,16 +24,16 @@
+ (void)initialize
{
// Register transformers
NSValueTransformer *stringToURLTransformer = [[[StringToURLTransformer alloc] init]autorelease];
NSValueTransformer *stringToURLTransformer = [[StringToURLTransformer alloc] init];
[NSValueTransformer setValueTransformer:stringToURLTransformer
forName:@"StringToURLTransformer"];
NSValueTransformer *fontSizetoLineHeightTransformer =
[[[FontSizetoLineHeightTransformer alloc] init]autorelease];
[[FontSizetoLineHeightTransformer alloc] init];
[NSValueTransformer setValueTransformer:fontSizetoLineHeightTransformer
forName:@"FontSizetoLineHeightTransformer"];
NSValueTransformer *miniModeMenuTitleTransformer = [[[MiniModeMenuTitleTransformer alloc] init] autorelease];
NSValueTransformer *miniModeMenuTitleTransformer = [[MiniModeMenuTitleTransformer alloc] init];
[NSValueTransformer setValueTransformer:miniModeMenuTitleTransformer
forName:@"MiniModeMenuTitleTransformer"];
}
@ -45,133 +46,12 @@
{
[self initDefaults];
remote = [[AppleRemote alloc] init];
[remote setDelegate: self];
queue = [[NSOperationQueue alloc]init];
}
return self;
}
- (void)dealloc
{
[queue release];
[expandedNodes release];
[super dealloc];
}
// Listen to the remote in exclusive mode, only when Cog is the active application
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
[remote startListening: self];
}
}
- (void)applicationDidResignActive:(NSNotification *)notification
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
[remote stopListening: self];
}
}
/* Helper method for the remote control interface in order to trigger forward/backward and volume
increase/decrease as long as the user holds the left/right, plus/minus button */
- (void) executeHoldActionForRemoteButton: (NSNumber*) buttonIdentifierNumber
{
static int incrementalSearch = 1;
if (remoteButtonHeld)
{
switch([buttonIdentifierNumber intValue])
{
case kRemoteButtonRight_Hold:
[playbackController seekForward:incrementalSearch];
break;
case kRemoteButtonLeft_Hold:
[playbackController seekBackward:incrementalSearch];
break;
case kRemoteButtonVolume_Plus_Hold:
//Volume Up
[playbackController volumeUp:self];
break;
case kRemoteButtonVolume_Minus_Hold:
//Volume Down
[playbackController volumeDown:self];
break;
}
if (remoteButtonHeld)
{
/* there should perhaps be a max amount that incrementalSearch can
be, so as to not start skipping ahead unreasonable amounts, even
in very long files. */
if ((incrementalSearch % 3) == 0)
incrementalSearch += incrementalSearch/3;
else
incrementalSearch++;
/* trigger event */
[self performSelector:@selector(executeHoldActionForRemoteButton:)
withObject:buttonIdentifierNumber
afterDelay:0.25];
}
}
else
// if we're not holding the search button, reset the incremental search
// variable, making it ready for another search
incrementalSearch = 1;
}
/* Apple Remote callback */
- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier
pressedDown: (BOOL) pressedDown
clickCount: (unsigned int) count
{
switch( buttonIdentifier )
{
case k2009RemoteButtonPlay:
case kRemoteButtonPlay:
[self clickPlay];
break;
case kRemoteButtonVolume_Plus:
[playbackController volumeUp:self];
break;
case kRemoteButtonVolume_Minus:
[playbackController volumeDown:self];
break;
case kRemoteButtonRight:
[self clickNext];
break;
case kRemoteButtonLeft:
[self clickPrev];
break;
case kRemoteButtonRight_Hold:
case kRemoteButtonLeft_Hold:
case kRemoteButtonVolume_Plus_Hold:
case kRemoteButtonVolume_Minus_Hold:
/* simulate an event as long as the user holds the button */
remoteButtonHeld = pressedDown;
if( pressedDown )
{
NSNumber* buttonIdentifierNumber = [NSNumber numberWithInt: buttonIdentifier];
[self performSelector:@selector(executeHoldActionForRemoteButton:)
withObject:buttonIdentifierNumber];
}
break;
case kRemoteButtonMenu:
break;
case k2009RemoteButtonFullscreen:
[mainWindow toggleFullScreen:nil];
break;
default:
/* Add here whatever you want other buttons to do */
break;
}
}
- (IBAction)openFiles:(id)sender
{
NSOpenPanel *p;
@ -256,12 +136,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[self registerHotKeys];
[spotlightWindowController init];
//Init Remote
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && ![[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
[remote startListening:self];
}
(void) [spotlightWindowController init];
[[playlistController undoManager] disableUndoRegistration];
NSString *basePath = [@"~/Library/Application Support/Cog/" stringByExpandingTildeInPath];
@ -479,9 +354,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:8] forKey:@"hotKeySpamKeyCode"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeySpamModifiers"];
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:YES] forKey:@"remoteEnabled"];
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:YES] forKey:@"remoteOnlyOnActive"];
NSString * feedURLdefault = @"https://www.kode54.net/cog/mercury.xml";
NSString * feedURLbroken = @"https://kode54.net/cog/stable.xml";
NSString * feedURLbroken2 = @"https://kode54.net/cog/mercury.xml";
@ -518,9 +390,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.hotKeyNextKeyCode" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
forKeyPath:@"values.hotKeySpamKeyCode" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.remoteEnabled" options:0 context:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.remoteOnlyOnActive" options:0 context:nil];
}
- (void) observeValueForKeyPath:(NSString *)keyPath
@ -540,25 +409,10 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
else if ([keyPath isEqualToString:@"values.hotKeySpamKeyCode"]) {
[self registerHotKeys];
}
else if ([keyPath isEqualToString:@"values.remoteEnabled"] || [keyPath isEqualToString:@"values.remoteOnlyOnActive"]) {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) {
BOOL onlyOnActive = [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"];
if (!onlyOnActive || [NSApp isActive]) {
[remote startListening: self];
}
if (onlyOnActive && ![NSApp isActive]) { //Setting a preference without being active? *shrugs*
[remote stopListening: self];
}
}
else {
[remote stopListening: self];
}
}
}
- (void)registerHotKeys
{
[playHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayKeyCode"] intValue]) {
playHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPlayKeyCode"] intValue]
@ -568,7 +422,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[playHotKey setEnabled:YES];
}
[prevHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyPreviousKeyCode"] intValue]) {
prevHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyPreviousKeyCode"]
@ -578,7 +431,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[prevHotKey setEnabled:YES];
}
[nextHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeyNextKeyCode"] intValue]) {
nextHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeyNextKeyCode"]
@ -588,7 +440,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[nextHotKey setEnabled:YES];
}
[spamHotKey release];
if ([[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"hotKeySpamKeyCode"] intValue]) {
spamHotKey = [[NDHotKeyEvent alloc]
initWithKeyCode: [[NSUserDefaults standardUserDefaults] integerForKey:@"hotKeySpamKeyCode"]
@ -605,7 +456,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
if (nil == nowPlaying)
{
nowPlaying = [[NowPlayingBarController alloc] init];
[nowPlaying retain];
NSView *contentView = [mainWindow contentView];
NSRect contentRect = [contentView frame];
@ -638,7 +488,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
// [mainView setFrameOrigin:NSMakePoint(0.0, 0.0)];
[[nowPlaying view] removeFromSuperview];
[nowPlaying release];
nowPlaying = nil;
}
}

View File

@ -8,6 +8,7 @@
#import "DockIconController.h"
#import <CogAudio/Status.h>
#import "PlaybackController.h"
@implementation DockIconController
@ -15,8 +16,8 @@ static NSString *DockIconPlaybackStatusObservationContext = @"DockIconPlaybackSt
- (void)startObserving
{
[playbackController addObserver:self forKeyPath:@"playbackStatus" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:DockIconPlaybackStatusObservationContext];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.colorfulDockIcons" options:0 context:DockIconPlaybackStatusObservationContext];
[playbackController addObserver:self forKeyPath:@"playbackStatus" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:(__bridge void * _Nullable)(DockIconPlaybackStatusObservationContext)];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.colorfulDockIcons" options:0 context:(__bridge void * _Nullable)(DockIconPlaybackStatusObservationContext)];
}
- (void)stopObserving
@ -69,12 +70,11 @@ static NSString *getBadgeName(NSString *baseName, BOOL colorfulIcons)
[newDockImage unlockFocus];
[NSApp setApplicationIconImage:newDockImage];
[newDockImage release];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([DockIconPlaybackStatusObservationContext isEqual:context])
if ([DockIconPlaybackStatusObservationContext isEqual:(__bridge id)(context)])
{
if ([keyPath isEqualToString:@"playbackStatus"])
{
@ -102,9 +102,6 @@ static NSString *getBadgeName(NSString *baseName, BOOL colorfulIcons)
- (void)dealloc
{
[self stopObserving];
[dockImage release];
[super dealloc];
}
@end

View File

@ -66,15 +66,6 @@ typedef enum
return self;
}
- (void)dealloc
{
[queue release];
[entry release];
[super dealloc];
}
- (NSDictionary *)fillNotificationDictionary:(PlaylistEntry *)pe status:(TrackStatus)status
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
@ -105,8 +96,7 @@ typedef enum
- (void)performPlaybackDidBeginActions:(PlaylistEntry *)pe
{
if (NO == [pe error]) {
[entry release];
entry = [pe retain];
entry = pe;
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:TrackNotification object:nil userInfo:[self fillNotificationDictionary:pe status:TrackPlaying] deliverImmediately:YES];
@ -180,7 +170,6 @@ typedef enum
- (void)performPlaybackDidStopActions
{
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:TrackNotification object:nil userInfo:[self fillNotificationDictionary:entry status:TrackStopped] deliverImmediately:YES];
[entry release];
entry = nil;
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
[scrobbler stop];
@ -220,28 +209,24 @@ typedef enum
{
NSOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(performPlaybackDidBeginActions:) object:[notification object]];
[queue addOperation:op];
[op release];
}
- (void)playbackDidPause:(NSNotification *)notification
{
NSOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(performPlaybackDidPauseActions) object:nil];
[queue addOperation:op];
[op release];
}
- (void)playbackDidResume:(NSNotification *)notification
{
NSOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(performPlaybackDidResumeActions) object:nil];
[queue addOperation:op];
[op release];
}
- (void)playbackDidStop:(NSNotification *)notification
{
NSOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(performPlaybackDidStopActions) object:nil];
[queue addOperation:op];
[op release];
}
- (NSDictionary *) registrationDictionaryForGrowl

View File

@ -13,6 +13,6 @@
}
+ (NSDictionary *)putMetadataInURL:(NSURL *)url;
+ (int)putMetadataInURL:(NSURL *)url;
@end

View File

@ -10,7 +10,7 @@
#import "PluginController.h"
@implementation AudioMetadataWriter
+ (NSDictionary *)putMetadataInURL:(NSURL *)url
+ (int)putMetadataInURL:(NSURL *)url
{
return [[PluginController sharedPluginController] putMetadataInURL:url];
}

View File

@ -24,7 +24,7 @@
if (self)
{
output = NULL;
bufferChain = NULL;
bufferChain = nil;
outputLaunched = NO;
endOfInputReached = NO;
@ -55,10 +55,6 @@
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused
{
if (output)
{
[output release];
}
output = [[OutputNode alloc] initWithController:self previous:nil];
[output setup];
[output setVolume: volume];
@ -73,7 +69,7 @@
{
[bufferChain setShouldContinue:NO];
[bufferChain release];
bufferChain = nil;
}
}
@ -82,7 +78,6 @@
while (![bufferChain open:url withOutputFormat:[output format] withRGInfo:rgi])
{
[bufferChain release];
bufferChain = nil;
[self requestNextStream: userInfo];
@ -173,16 +168,10 @@
- (void)setNextStream:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi
{
[url retain];
[nextStream release];
nextStream = url;
[userInfo retain];
[nextStreamUserInfo release];
nextStreamUserInfo = userInfo;
[rgi retain];
[nextStreamRGInfo release];
nextStreamRGInfo = rgi;
}
@ -261,10 +250,8 @@
BufferChain *newChain = nil;
nextStreamUserInfo = [sender userInfo];
[nextStreamUserInfo retain]; //Retained because when setNextStream is called, it will be released!!!
nextStreamRGInfo = [sender rgInfo];
[nextStreamRGInfo retain];
[self requestNextStream: nextStreamUserInfo];
@ -293,29 +280,31 @@
[self addChainToQueue:newChain];
DLog(@"TRACK SET!!! %@", newChain);
//Keep on-playin
[newChain release];
newChain = nil;
return NO;
}
}
lastChain = nil;
while (![newChain open:nextStream withOutputFormat:[output format] withRGInfo:nextStreamRGInfo])
{
if (nextStream == nil)
{
[newChain release];
newChain = nil;
return YES;
}
[newChain release];
newChain = nil;
[self requestNextStream: nextStreamUserInfo];
newChain = [[BufferChain alloc] initWithController:self];
}
[self addChainToQueue:newChain];
[newChain release];
newChain = nil;
// I'm stupid and can't hold too much stuff in my head all at once, so writing it here.
//
@ -347,17 +336,13 @@
//End of playlist
[self stop];
[bufferChain release];
bufferChain = nil;
return;
}
BufferChain *oldChain = bufferChain;
bufferChain = nil;
bufferChain = [chainQueue objectAtIndex:0];
[oldChain release];
[bufferChain retain];
[chainQueue removeObjectAtIndex:0];
DLog(@"New!!! %@ %@", bufferChain, [[bufferChain inputNode] decoder]);
@ -370,30 +355,29 @@
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj waitUntilDone:(BOOL)wait
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[delegate methodSignatureForSelector:selector]];
[invocation setTarget:delegate];
[invocation setSelector:selector];
[invocation setArgument:&self atIndex:2]; //Indexes start at 2, the first being self, the second being command.
[invocation setArgument:&self atIndex:2];
[invocation setArgument:&obj atIndex:3];
[invocation retainArguments];
[self performSelectorOnMainThread:@selector(sendDelegateMethodMainThread:) withObject:invocation waitUntilDone:wait];
[invocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:wait];
}
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj withObject:(id)obj2 waitUntilDone:(BOOL)wait
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[delegate methodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setArgument:&self atIndex:2]; //Indexes start at 2, the first being self, the second being command.
[invocation setTarget:delegate];
[invocation setSelector:selector];
[invocation setArgument:&self atIndex:2];
[invocation setArgument:&obj atIndex:3];
[invocation setArgument:&obj2 atIndex:4];
[invocation retainArguments];
[self performSelectorOnMainThread:@selector(sendDelegateMethodMainThread:) withObject:invocation waitUntilDone:wait];
[invocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:wait];
}
- (void)sendDelegateMethodMainThread:(id)invocation
{
[invocation invokeWithTarget:delegate];
}
- (void)setPlaybackStatus:(int)status waitUntilDone:(BOOL)wait
{
[self sendDelegateMethod:@selector(audioPlayer:didChangeStatus:userInfo:) withObject:[NSNumber numberWithInt:status] withObject:[bufferChain userInfo] waitUntilDone:wait];

View File

@ -34,9 +34,9 @@
- (void)buildChain
{
[inputNode release];
[converterNode release];
inputNode = nil;
converterNode = nil;
inputNode = [[InputNode alloc] initWithController:self previous:nil];
converterNode = [[ConverterNode alloc] initWithController:self previous:inputNode];
@ -100,8 +100,6 @@
- (void)setUserInfo:(id)i
{
[i retain];
[userInfo release];
userInfo = i;
}
@ -112,8 +110,6 @@
- (void)setRGInfo:(NSDictionary *)rgi
{
[rgi retain];
[rgInfo release];
rgInfo = rgi;
[converterNode setRGInfo:rgi];
}
@ -130,16 +126,7 @@
[[inputNode semaphore] signal];
[[inputNode exitAtTheEndOfTheStream] wait]; // wait for decoder to be closed (see InputNode's -(void)process )
[rgInfo release];
[userInfo release];
[streamURL release];
[inputNode release];
[converterNode release];
DLog(@"Bufferchain dealloc");
[super dealloc];
}
- (void)seek:(double)time
@ -188,9 +175,6 @@
- (void)setStreamURL:(NSURL *)url
{
[url retain];
[streamURL release];
streamURL = url;
}

View File

@ -109,7 +109,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter,
AudioStreamPacketDescription** outDataPacketDescription,
void* inUserData)
{
ConverterNode *converter = (ConverterNode *)inUserData;
ConverterNode *converter = (__bridge ConverterNode *)inUserData;
OSStatus err = noErr;
int amountToWrite;
int amountRead;
@ -149,7 +149,7 @@ static OSStatus ACFloatProc(AudioConverterRef inAudioConverter,
AudioStreamPacketDescription** outDataPacketDescription,
void* inUserData)
{
ConverterNode *converter = (ConverterNode *)inUserData;
ConverterNode *converter = (__bridge ConverterNode *)inUserData;
OSStatus err = noErr;
int amountToWrite;
@ -204,7 +204,7 @@ static OSStatus ACFloatProc(AudioConverterRef inAudioConverter,
ioData.mNumberBuffers = 1;
tryagain:
err = AudioConverterFillComplexBuffer(converterFloat, ACInputProc, self, &ioNumberFrames, &ioData, NULL);
err = AudioConverterFillComplexBuffer(converterFloat, ACInputProc, (__bridge void * _Nullable)(self), &ioNumberFrames, &ioData, NULL);
amountRead += ioData.mBuffers[0].mDataByteSize;
if (err == 100)
{
@ -239,7 +239,7 @@ static OSStatus ACFloatProc(AudioConverterRef inAudioConverter,
amountRead = 0;
tryagain2:
err = AudioConverterFillComplexBuffer(converter, ACFloatProc, self, &ioNumberFrames, &ioData, NULL);
err = AudioConverterFillComplexBuffer(converter, ACFloatProc, (__bridge void *)(self), &ioNumberFrames, &ioData, NULL);
amountRead += ioData.mBuffers[0].mDataByteSize;
if (err == 100)
{
@ -387,7 +387,6 @@ static float db_to_scale(float db)
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.volumeScaling"];
[self cleanUp];
[super dealloc];
}
@ -407,15 +406,12 @@ static float db_to_scale(float db)
- (void)setRGInfo:(NSDictionary *)rgi
{
DLog(@"Setting ReplayGain info");
[rgInfo release];
[rgi retain];
rgInfo = rgi;
[self refreshVolumeScaling];
}
- (void)cleanUp
{
[rgInfo release];
rgInfo = nil;
if (converterFloat)
{

View File

@ -33,7 +33,6 @@
- (BOOL)openWithSource:(id<CogSource>)source
{
decoder = [AudioDecoder audioDecoderForSource:source];
[decoder retain];
if (decoder == nil)
return NO;
@ -62,7 +61,6 @@
{
DLog(@"Opening with old decoder: %@", d);
decoder = d;
[decoder retain];
NSDictionary *properties = [decoder properties];
int bitsPerSample = [[properties objectForKey:@"bitsPerSample"] intValue];
@ -218,11 +216,6 @@
DLog(@"Input Node dealloc");
[decoder removeObserver:self forKeyPath:@"properties"];
[decoder removeObserver:self forKeyPath:@"metadata"];
[decoder release];
[exitAtTheEndOfTheStream release];
[super dealloc];
}
- (NSDictionary *) properties

View File

@ -19,8 +19,8 @@
NSLock *readLock;
NSLock *writeLock;
id previousNode;
id controller;
id __weak previousNode;
id __weak controller;
BOOL shouldReset;

View File

@ -85,15 +85,9 @@
- (void)threadEntry:(id)arg
{
[self retain];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[self process];
[pool release];
[self release];
@autoreleasepool {
[self process];
}
}
- (int)readData:(void *)ptr amount:(int)amount
@ -158,8 +152,6 @@
- (void)setPreviousNode:(id)p
{
[p retain];
[previousNode release];
previousNode = p;
}
@ -228,16 +220,4 @@
}
- (void)dealloc
{
[previousNode release];
[buffer release];
[semaphore release];
[readLock release];
[writeLock release];
[super dealloc];
}
@end

View File

@ -53,27 +53,26 @@
- (int)readData:(void *)ptr amount:(int)amount
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int n;
[self setPreviousNode:[[controller bufferChain] finalNode]];
@autoreleasepool {
int n;
[self setPreviousNode:[[controller bufferChain] finalNode]];
n = [super readData:ptr amount:amount];
amountPlayed += n;
n = [super readData:ptr amount:amount];
amountPlayed += n;
if (endOfStream == YES)
{
amountPlayed = 0;
[controller endOfInputPlayed]; //Updates shouldContinue appropriately?
}
if (endOfStream == YES)
{
amountPlayed = 0;
[controller endOfInputPlayed]; //Updates shouldContinue appropriately?
}
/* if (n == 0) {
DLog(@"Output Buffer dry!");
}
*/
[pool release];
return n;
return n;
}
}
@ -97,13 +96,6 @@
[output stop];
}
- (void)dealloc
{
[output release];
[super dealloc];
}
- (void)setVolume:(double) v
{
[output setVolume:v];

View File

@ -362,7 +362,7 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
LastUpgradeCheck = 0730;
TargetAttributes = {
8DC2EF4F0486A6940098B216 = {
DevelopmentTeam = N6E749HJ2X;
@ -445,6 +445,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = org.cogx.cogaudio;
PRODUCT_NAME = CogAudio;
PROVISIONING_PROFILE = "";
SDKROOT = macosx;
@ -470,6 +471,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = org.cogx.cogaudio;
PRODUCT_NAME = CogAudio;
PROVISIONING_PROFILE = "";
SDKROOT = macosx;
@ -482,6 +484,8 @@
1DEB91B208733DA50010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
ENABLE_TESTABILITY = YES;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
@ -496,6 +500,7 @@
1DEB91B308733DA50010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "Developer ID Application";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_WARN_ABOUT_RETURN_TYPE = YES;

View File

@ -59,12 +59,6 @@ NSArray * sortClassesByPriority(NSArray * theClasses)
return self;
}
- (void)dealloc
{
[cachedObservers release];
[super dealloc];
}
- (NSDictionary *)properties
{
if ( theDecoder != nil ) return [theDecoder properties];
@ -84,14 +78,13 @@ NSArray * sortClassesByPriority(NSArray * theClasses)
Class decoder = NSClassFromString(classString);
theDecoder = [[decoder alloc] init];
for (NSDictionary *obsItem in cachedObservers) {
[theDecoder addObserver:[obsItem objectForKey:@"observer"] forKeyPath:[obsItem objectForKey:@"keyPath"] options:[obsItem objectForKey:@"options"] context:[obsItem objectForKey:@"context"]];
[theDecoder addObserver:[obsItem objectForKey:@"observer"] forKeyPath:[obsItem objectForKey:@"keyPath"] options:[obsItem objectForKey:@"options"] context:(__bridge void *)([obsItem objectForKey:@"context"])];
}
if ([theDecoder open:source])
return YES;
for (NSDictionary *obsItem in cachedObservers) {
[theDecoder removeObserver:[obsItem objectForKey:@"observer"] forKeyPath:[obsItem objectForKey:@"keyPath"]];
}
[theDecoder release];
[source seek:0 whence:SEEK_SET];
}
theDecoder = nil;
@ -111,7 +104,6 @@ NSArray * sortClassesByPriority(NSArray * theClasses)
for (NSDictionary *obsItem in cachedObservers) {
[theDecoder removeObserver:[obsItem objectForKey:@"observer"] forKeyPath:[obsItem objectForKey:@"keyPath"]];
}
[theDecoder release];
theDecoder = nil;
}
}

View File

@ -6,14 +6,14 @@
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.cogx.cogaudio</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>

View File

@ -1,4 +1,4 @@
//
//
// OutputCoreAudio.m
// Cog
//
@ -29,7 +29,7 @@
static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
{
OutputCoreAudio *output = (OutputCoreAudio *)inRefCon;
OutputCoreAudio *output = (__bridge OutputCoreAudio *)inRefCon;
OSStatus err = noErr;
void *readPointer = ioData->mBuffers[0].mData;
@ -286,7 +286,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
//setup render callbacks
renderCallback.inputProc = Sound_Renderer;
renderCallback.inputProcRefCon = self;
renderCallback.inputProcRefCon = (__bridge void * _Nullable)(self);
AudioUnitSetProperty(outputUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &renderCallback, sizeof(AURenderCallbackStruct));
@ -326,8 +326,6 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
[self stop];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"];
[super dealloc];
}
- (void)pause

View File

@ -35,16 +35,16 @@ static PluginController *sharedPluginController = nil;
- (id)init {
self = [super init];
if (self) {
self.sources = [[[NSMutableDictionary alloc] init] autorelease];
self.containers = [[[NSMutableDictionary alloc] init] autorelease];
self.sources = [[NSMutableDictionary alloc] init];
self.containers = [[NSMutableDictionary alloc] init];
self.metadataReaders = [[[NSMutableDictionary alloc] init] autorelease];
self.metadataReaders = [[NSMutableDictionary alloc] init];
self.propertiesReadersByExtension = [[[NSMutableDictionary alloc] init] autorelease];
self.propertiesReadersByMimeType = [[[NSMutableDictionary alloc] init] autorelease];
self.propertiesReadersByExtension = [[NSMutableDictionary alloc] init];
self.propertiesReadersByMimeType = [[NSMutableDictionary alloc] init];
self.decodersByExtension = [[[NSMutableDictionary alloc] init] autorelease];
self.decodersByMimeType = [[[NSMutableDictionary alloc] init] autorelease];
self.decodersByExtension = [[NSMutableDictionary alloc] init];
self.decodersByMimeType = [[NSMutableDictionary alloc] init];
[self setup];
}
@ -123,7 +123,7 @@ static PluginController *sharedPluginController = nil;
NSMutableArray *containerSet;
if (![containers objectForKey:ext])
{
containerSet = [[[NSMutableArray alloc] init] autorelease];
containerSet = [[NSMutableArray alloc] init];
[containers setObject:containerSet forKey:ext];
}
else
@ -143,7 +143,7 @@ static PluginController *sharedPluginController = nil;
NSMutableArray *decoders;
if (![decodersByExtension objectForKey:ext])
{
decoders = [[[NSMutableArray alloc] init] autorelease];
decoders = [[NSMutableArray alloc] init];
[decodersByExtension setObject:decoders forKey:ext];
}
else
@ -170,7 +170,7 @@ static PluginController *sharedPluginController = nil;
NSMutableArray *readers;
if (![metadataReaders objectForKey:ext])
{
readers = [[[NSMutableArray alloc] init] autorelease];
readers = [[NSMutableArray alloc] init];
[metadataReaders setObject:readers forKey:ext];
}
else
@ -190,7 +190,7 @@ static PluginController *sharedPluginController = nil;
NSMutableArray *readers;
if (![propertiesReadersByExtension objectForKey:ext])
{
readers = [[[NSMutableArray alloc] init] autorelease];
readers = [[NSMutableArray alloc] init];
[propertiesReadersByExtension setObject:readers forKey:ext];
}
else
@ -237,7 +237,7 @@ static PluginController *sharedPluginController = nil;
Class source = NSClassFromString([sources objectForKey:scheme]);
return [[[source alloc] init] autorelease];
return [[source alloc] init];
}
- (NSArray *) urlsForContainerURL:(NSURL *)url
@ -270,7 +270,7 @@ static PluginController *sharedPluginController = nil;
NSString *classString;
if (decoders) {
if ( [decoders count] > 1 ) {
return [[[CogDecoderMulti alloc] initWithDecoders:decoders] autorelease];
return [[CogDecoderMulti alloc] initWithDecoders:decoders];
}
else {
classString = [decoders objectAtIndex:0];
@ -282,7 +282,7 @@ static PluginController *sharedPluginController = nil;
Class decoder = NSClassFromString(classString);
return [[[decoder alloc] init] autorelease];
return [[decoder alloc] init];
}
- (NSDictionary *)metadataForURL:(NSURL *)url

View File

@ -40,8 +40,8 @@ static void deallocateVirtualBuffer(void *buffer, UInt32 bufferLength);
if (buffer) {
bufferEnd = buffer + bufferLength;
} else {
[self release];
return nil;
self = nil;
return nil;
}
readPointer = NULL;
@ -54,8 +54,6 @@ static void deallocateVirtualBuffer(void *buffer, UInt32 bufferLength);
{
if (buffer)
deallocateVirtualBuffer(buffer, bufferLength);
[super dealloc];
}
- (void)empty

View File

@ -43,7 +43,7 @@ escapeForLastFM(NSString *string)
options:NSLiteralSearch
range:NSMakeRange(0, [result length])];
return (nil == result ? @"" : [result autorelease]);
return (nil == result ? @"" : result);
}
@interface AudioScrobbler (Private)
@ -101,7 +101,7 @@ escapeForLastFM(NSString *string)
if(KERN_SUCCESS != result) {
ALog(@"Couldn't create semaphore (%s).", mach_error_type(result));
[self release];
self = nil;
return nil;
}
@ -115,11 +115,9 @@ escapeForLastFM(NSString *string)
if([self keepProcessingAudioScrobblerCommands] || NO == [self audioScrobblerThreadCompleted])
[self shutdown];
[_queue release], _queue = nil;
_queue = nil;
semaphore_destroy(mach_task_self(), _semaphore), _semaphore = 0;
[super dealloc];
}
- (void) start:(PlaylistEntry *)pe
@ -212,76 +210,71 @@ escapeForLastFM(NSString *string)
- (void) processAudioScrobblerCommands:(id)unused
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init];
mach_timespec_t timeout = { 5, 0 };
NSString *command = nil;
NSString *response = nil;
in_port_t port = 33367;
@autoreleasepool {
AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init];
mach_timespec_t timeout = { 5, 0 };
NSString *command = nil;
NSString *response = nil;
in_port_t port = 33367;
while([self keepProcessingAudioScrobblerCommands]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
while([self keepProcessingAudioScrobblerCommands]) {
@autoreleasepool {
// Get the first command to be sent
@synchronized([self queue]) {
if ([[self queue] count]) {
command = [[[self queue] objectAtIndex:0] retain];
[[self queue] removeObjectAtIndex:0];
}
}
// Get the first command to be sent
@synchronized([self queue]) {
if ([[self queue] count]) {
command = [[self queue] objectAtIndex:0];
[[self queue] removeObjectAtIndex:0];
}
}
if(nil != command) {
@try {
if([client connectToHost:@"localhost" port:port]) {
port = [client connectedPort];
[client send:command];
[command release];
command = nil;
if(nil != command) {
@try {
if([client connectToHost:@"localhost" port:port]) {
port = [client connectedPort];
[client send:command];
command = nil;
response = [client receive];
if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)])
ALog(@"AudioScrobbler error: %@", response);
response = [client receive];
if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)])
ALog(@"AudioScrobbler error: %@", response);
[client shutdown];
}
}
[client shutdown];
}
}
@catch(NSException *exception) {
[command release];
command = nil;
@catch(NSException *exception) {
command = nil;
[client shutdown];
// ALog(@"Exception: %@",exception);
[pool release];
continue;
}
}
[client shutdown];
// ALog(@"Exception: %@",exception);
continue;
}
}
semaphore_timedwait([self semaphore], timeout);
[pool release];
}
semaphore_timedwait([self semaphore], timeout);
}
}
// Send a final stop command to cleanup
@try {
if([client connectToHost:@"localhost" port:port]) {
[client send:[NSString stringWithFormat:@"STOP c=%@\n", [self pluginID]]];
// Send a final stop command to cleanup
@try {
if([client connectToHost:@"localhost" port:port]) {
[client send:[NSString stringWithFormat:@"STOP c=%@\n", [self pluginID]]];
response = [client receive];
if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)])
ALog(@"AudioScrobbler error: %@", response);
response = [client receive];
if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)])
ALog(@"AudioScrobbler error: %@", response);
[client shutdown];
}
}
[client shutdown];
}
}
@catch(NSException *exception) {
[client shutdown];
}
@catch(NSException *exception) {
[client shutdown];
}
[client release];
[self setAudioScrobblerThreadCompleted:YES];
[pool release];
[self setAudioScrobblerThreadCompleted:YES];
}
}
@end