diff --git a/TPAACAudioConverter.h b/TPAACAudioConverter.h old mode 100644 new mode 100755 diff --git a/TPAACAudioConverter.m b/TPAACAudioConverter.m old mode 100644 new mode 100755 index 372002c..b95a761 --- a/TPAACAudioConverter.m +++ b/TPAACAudioConverter.m @@ -15,7 +15,6 @@ NSString * TPAACAudioConverterErrorDomain = @"com.atastypixel.TPAACAudioConverterErrorDomain"; -#define checkResult(result,operation) (_checkResultLite((result),(operation),__FILE__,__LINE__)) static inline BOOL _checkResultLite(OSStatus result, const char *operation, const char* file, int line) { if ( result != noErr ) { @@ -24,6 +23,7 @@ static inline BOOL _checkResultLite(OSStatus result, const char *operation, cons } return YES; } +#define checkResult(result,operation) (_checkResultLite((result),(operation),__FILE__,__LINE__)) @interface TPAACAudioConverter () { BOOL _processing; @@ -107,12 +107,10 @@ - (id)initWithDelegate:(id)delegate dataSource:(id< } - (void)dealloc { - [_condition release]; self.source = nil; self.destination = nil; self.delegate = nil; self.dataSource = nil; - [super dealloc]; } -(void)start { @@ -128,7 +126,6 @@ -(void)start { _cancelled = NO; _processing = YES; - [self retain]; [self performSelectorInBackground:@selector(processingThread) withObject:nil]; } @@ -142,7 +139,6 @@ -(void)cancel { checkResult(AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof (allowMixing), &allowMixing), "AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers)"); } - [self autorelease]; } - (void)interrupt { @@ -171,7 +167,6 @@ - (void)reportCompletion { checkResult(AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof (allowMixing), &allowMixing), "AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers)"); } - [self autorelease]; } - (void)reportErrorAndCleanup:(NSError*)error { @@ -182,25 +177,23 @@ - (void)reportErrorAndCleanup:(NSError*)error { checkResult(AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof (allowMixing), &allowMixing), "AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers)"); } - [self autorelease]; [_delegate AACAudioConverter:self didFailWithError:error]; } - (void)processingThread { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [[NSThread currentThread] setThreadPriority:0.9]; ExtAudioFileRef sourceFile = NULL; AudioStreamBasicDescription sourceFormat; + NSLog(@"Opening path for compression %@: ", [NSURL fileURLWithPath:_source]); if ( _source ) { - if ( !checkResult(ExtAudioFileOpenURL((CFURLRef)[NSURL fileURLWithPath:_source], &sourceFile), "ExtAudioFileOpenURL") ) { + if ( !checkResult( ExtAudioFileOpenURL((__bridge CFURLRef)[NSURL fileURLWithPath:_source], &sourceFile) , "ExtAudioFileOpenURL") ) { [self performSelectorOnMainThread:@selector(reportErrorAndCleanup:) withObject:[NSError errorWithDomain:TPAACAudioConverterErrorDomain code:TPAACAudioConverterFileError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Couldn't open the source file", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -214,7 +207,6 @@ - (void)processingThread { code:TPAACAudioConverterFormatError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Couldn't read the source file", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -234,19 +226,17 @@ - (void)processingThread { code:TPAACAudioConverterFormatError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Couldn't setup destination format", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } ExtAudioFileRef destinationFile; - if ( !checkResult(ExtAudioFileCreateWithURL((CFURLRef)[NSURL fileURLWithPath:_destination], kAudioFileM4AType, &destinationFormat, NULL, kAudioFileFlags_EraseFile, &destinationFile), "ExtAudioFileCreateWithURL") ) { + if ( !checkResult(ExtAudioFileCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:_destination], kAudioFileM4AType, &destinationFormat, NULL, kAudioFileFlags_EraseFile, &destinationFile), "ExtAudioFileCreateWithURL") ) { [self performSelectorOnMainThread:@selector(reportErrorAndCleanup:) withObject:[NSError errorWithDomain:TPAACAudioConverterErrorDomain code:TPAACAudioConverterFileError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Couldn't open the source file", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -278,7 +268,6 @@ - (void)processingThread { code:TPAACAudioConverterFormatError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Couldn't setup intermediate conversion format", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -326,7 +315,6 @@ - (void)processingThread { code:TPAACAudioConverterFormatError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Error reading the source file", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -358,7 +346,6 @@ - (void)processingThread { code:TPAACAudioConverterUnrecoverableInterruptionError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Interrupted", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -399,7 +386,6 @@ - (void)processingThread { code:TPAACAudioConverterFormatError userInfo:[NSDictionary dictionaryWithObject:NSLocalizedString(@"Error writing the destination file", @"Error message") forKey:NSLocalizedDescriptionKey]] waitUntilDone:NO]; - [pool release]; _processing = NO; return; } @@ -421,7 +407,6 @@ - (void)processingThread { _processing = NO; - [pool release]; } @end