Cleaned up memory leaks.

CQTexperiment
vspader 2007-10-13 07:09:46 +00:00
parent 6f6b01b15c
commit 97a278a143
13 changed files with 61 additions and 6 deletions

View File

@ -253,6 +253,8 @@
- (void)endOfInputPlayed - (void)endOfInputPlayed
{ {
[bufferChain release];
if ([chainQueue count] <= 0) if ([chainQueue count] <= 0)
{ {
//End of playlist //End of playlist
@ -260,7 +262,6 @@
return; return;
} }
[bufferChain release];
bufferChain = [chainQueue objectAtIndex:0]; bufferChain = [chainQueue objectAtIndex:0];
[bufferChain retain]; [bufferChain retain];

View File

@ -105,10 +105,13 @@
- (void)dealloc - (void)dealloc
{ {
[userInfo release]; [userInfo release];
[streamURL release];
[inputNode release]; [inputNode release];
[converterNode release]; [converterNode release];
NSLog(@"Bufferchain dealloc");
[super dealloc]; [super dealloc];
} }

View File

@ -140,6 +140,14 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
return YES; return YES;
} }
- (void)dealloc
{
NSLog(@"Decoder dealloc");
[self cleanUp];
[super dealloc];
}
- (void)setOutputFormat:(AudioStreamBasicDescription)format - (void)setOutputFormat:(AudioStreamBasicDescription)format
{ {
NSLog(@"SETTING OUTPUT FORMAT!"); NSLog(@"SETTING OUTPUT FORMAT!");
@ -160,6 +168,9 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
AudioConverterDispose(converter); AudioConverterDispose(converter);
converter = NULL; converter = NULL;
} }
if (callbackBuffer) {
free(callbackBuffer);
}
} }
@end @end

View File

@ -151,7 +151,7 @@
- (void)dealloc - (void)dealloc
{ {
NSLog(@"DEALLOCATING"); NSLog(@"Input Node dealloc");
[decoder removeObserver:self forKeyPath:@"properties"]; [decoder removeObserver:self forKeyPath:@"properties"];
[decoder removeObserver:self forKeyPath:@"metadata"]; [decoder removeObserver:self forKeyPath:@"metadata"];

View File

@ -219,4 +219,14 @@
} }
- (void)dealloc
{
[buffer release];
[semaphore release];
[readLock release];
[writeLock release];
[super dealloc];
}
@end @end

View File

@ -235,6 +235,8 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
{ {
[self stop]; [self stop];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.outputDevice"];
[super dealloc]; [super dealloc];
} }

View File

@ -192,7 +192,7 @@ escapeForLastFM(NSString *string)
- (void) processAudioScrobblerCommands:(AudioScrobbler *)myself - (void) processAudioScrobblerCommands:(AudioScrobbler *)myself
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = nil;
AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init]; AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init];
mach_timespec_t timeout = { 5, 0 }; mach_timespec_t timeout = { 5, 0 };
NSEnumerator *enumerator = nil; NSEnumerator *enumerator = nil;
@ -201,6 +201,9 @@ escapeForLastFM(NSString *string)
in_port_t port = 33367; in_port_t port = 33367;
while([myself keepProcessingAudioScrobblerCommands]) { while([myself keepProcessingAudioScrobblerCommands]) {
if (pool)
[pool release];
pool = [[NSAutoreleasePool alloc] init];
// Get the first command to be sent // Get the first command to be sent
@synchronized([myself queue]) { @synchronized([myself queue]) {
@ -235,6 +238,8 @@ escapeForLastFM(NSString *string)
semaphore_timedwait([myself semaphore], timeout); semaphore_timedwait([myself semaphore], timeout);
} }
[pool release];
// Send a final stop command to cleanup // Send a final stop command to cleanup
@try { @try {
if([client connectToHost:@"localhost" port:port]) { if([client connectToHost:@"localhost" port:port]) {

View File

@ -24,7 +24,7 @@
result = [NSString stringWithFormat:@"%i", value]; result = [NSString stringWithFormat:@"%i", value];
return [[result retain] autorelease]; return result;
} }
- (BOOL) getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error - (BOOL) getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error

View File

@ -63,7 +63,7 @@
result = [NSString stringWithFormat:@"0:%.2u", seconds]; result = [NSString stringWithFormat:@"0:%.2u", seconds];
} }
return [[result retain] autorelease]; return result;
} }
- (BOOL) getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error - (BOOL) getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error

View File

@ -52,6 +52,8 @@
- (void)close - (void)close
{ {
[self setURL:nil];
fclose(_fd); fclose(_fd);
} }
@ -73,4 +75,10 @@
return [NSArray arrayWithObject:@"file"]; return [NSArray arrayWithObject:@"file"];
} }
- (void)dealloc {
NSLog(@"DEALLOCATING SOURCE");
[super dealloc];
}
@end @end

View File

@ -117,6 +117,8 @@
- (void)dealloc - (void)dealloc
{ {
[self setURL:nil];
[_socket release]; [_socket release];
[_url release]; [_url release];

View File

@ -548,13 +548,24 @@ static inline signed int scale (mad_fixed_t sample)
- (void)close - (void)close
{ {
[_source close]; if (_source)
{
[_source close];
[_source release];
_source = nil;
}
mad_synth_finish(&_synth); mad_synth_finish(&_synth);
mad_frame_finish(&_frame); mad_frame_finish(&_frame);
mad_stream_finish(&_stream); mad_stream_finish(&_stream);
} }
- (void)dealloc
{
NSLog(@"Decoder dealloc");
[super dealloc];
}
- (double)seekToTime:(double)milliseconds - (double)seekToTime:(double)milliseconds
{ {
unsigned long new_position; unsigned long new_position;

View File

@ -112,6 +112,8 @@ long sourceTell(void *datasource)
- (void)close - (void)close
{ {
ov_clear(&vorbisRef); ov_clear(&vorbisRef);
[source close];
[source release]; [source release];
} }