diff --git a/Application/AppController.m b/Application/AppController.m index 8652195f9..479a1b0ae 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -14,6 +14,8 @@ #import "PathNode.h" #import +#import "Logging.h" + @implementation AppController + (void)initialize @@ -298,13 +300,13 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ expandedNodes = [[NSMutableSet alloc] init]; } - NSLog(@"Nodes to expand: %@", [expandedNodes description]); + DLog(@"Nodes to expand: %@", [expandedNodes description]); - NSLog(@"Num of rows: %ld", [outlineView numberOfRows]); + DLog(@"Num of rows: %ld", [outlineView numberOfRows]); if (!outlineView) { - NSLog(@"outlineView is NULL!"); + DLog(@"outlineView is NULL!"); } [outlineView reloadData]; @@ -376,7 +378,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ NSError *error; [[NSFileManager defaultManager] removeItemAtPath:[folder stringByAppendingPathComponent:fileName] error:&error]; - NSLog(@"Saving expanded nodes: %@", [expandedNodes description]); + DLog(@"Saving expanded nodes: %@", [expandedNodes description]); [[NSUserDefaults standardUserDefaults] setValue:[expandedNodes allObjects] forKey:@"fileTreeViewExpandedNodes"]; } @@ -583,7 +585,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ - (void)windowDidEnterFullScreen:(NSNotification *)notification { - NSLog(@"Entering fullscreen"); + DLog(@"Entering fullscreen"); if (nil == nowPlaying) { nowPlaying = [[NowPlayingBarController alloc] init]; @@ -610,7 +612,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ - (void)windowDidExitFullScreen:(NSNotification *)notification { - NSLog(@"Exiting fullscreen"); + DLog(@"Exiting fullscreen"); if (nowPlaying) { NSRect nowPlayingFrame = [[nowPlaying view] frame]; diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index 6583c90e6..0496f902d 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -8,6 +8,8 @@ #import "PlaylistEntry.h" #import "playlistLoader.h" +#import "Logging.h" + @implementation PlaybackController #define DEFAULT_SEEK 5 @@ -139,7 +141,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) if (playbackStatus != kCogStatusStopped) [self stop:self]; - NSLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]); + DLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]); [playlistController setCurrentEntry:pe]; [self setPosition:0.0]; @@ -242,7 +244,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) if (img == nil) { - NSLog(@"Error loading image!"); + DLog(@"Error loading image!"); } [playbackButtons setImage:img forSegment:1]; @@ -250,7 +252,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) */ - (IBAction)changeVolume:(id)sender { - NSLog(@"VOLUME: %lf, %lf", [sender doubleValue], linearToLogarithmic([sender doubleValue])); + DLog(@"VOLUME: %lf, %lf", [sender doubleValue], linearToLogarithmic([sender doubleValue])); [audioPlayer setVolume:linearToLogarithmic([sender doubleValue])]; @@ -266,7 +268,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) double originalVolume = [[audioTimer userInfo] doubleValue]; double down = originalVolume/10; - NSLog(@"VOLUME IS %lf", volume); + DLog(@"VOLUME IS %lf", volume); if (volume > 0.0001) //YAY! Roundoff error! { @@ -290,7 +292,7 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) double originalVolume = [[audioTimer userInfo] doubleValue]; double up = originalVolume/10; - NSLog(@"VOLUME IS %lf", volume); + DLog(@"VOLUME IS %lf", volume); if (volume < originalVolume) { @@ -517,12 +519,12 @@ NSDictionary * makeRGInfo(PlaylistEntry *pe) } if (status == kCogStatusStopped) { - NSLog(@"DONE!"); + DLog(@"DONE!"); [playlistController setCurrentEntry:nil]; [self setSeekable:NO]; // the player stopped, disable the slider } else { - NSLog(@"PLAYING!"); + DLog(@"PLAYING!"); [self setSeekable:YES]; } diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index f95d9e495..33db458f7 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -14,6 +14,8 @@ #import "PluginController.h" +#import "Logging.h" + @implementation AudioPlayer - (id)init @@ -259,7 +261,7 @@ [newChain setUserInfo:nextStreamUserInfo]; [self addChainToQueue:newChain]; - NSLog(@"TRACK SET!!! %@", newChain); + DLog(@"TRACK SET!!! %@", newChain); //Keep on-playin [newChain release]; @@ -310,7 +312,7 @@ bufferChain = [chainQueue objectAtIndex:0]; [bufferChain retain]; - NSLog(@"New!!! %@ %@", bufferChain, [[bufferChain inputNode] decoder]); + DLog(@"New!!! %@ %@", bufferChain, [[bufferChain inputNode] decoder]); [chainQueue removeObjectAtIndex:0]; } diff --git a/Audio/Chain/BufferChain.m b/Audio/Chain/BufferChain.m index 1cf6a64d1..b72f8cbad 100644 --- a/Audio/Chain/BufferChain.m +++ b/Audio/Chain/BufferChain.m @@ -11,6 +11,8 @@ #import "AudioSource.h" #import "CoreAudioUtils.h" +#import "Logging.h" + @implementation BufferChain - (id)initWithController:(id)c @@ -48,10 +50,10 @@ [self buildChain]; id source = [AudioSource audioSourceForURL:url]; - NSLog(@"Opening: %@", url); + DLog(@"Opening: %@", url); if (![source open:url]) { - NSLog(@"Couldn't open source..."); + DLog(@"Couldn't open source..."); return NO; } @@ -68,24 +70,26 @@ return YES; } -- (BOOL)openWithInput:(InputNode *)i withOutputFormat:(AudioStreamBasicDescription)outputFormat +- (BOOL)openWithInput:(InputNode *)i withOutputFormat:(AudioStreamBasicDescription)outputFormat withRGInfo:(NSDictionary *)rgi { - NSLog(@"New buffer chain!"); + DLog(@"New buffer chain!"); [self buildChain]; if (![inputNode openWithDecoder:[i decoder]]) return NO; - NSLog(@"Input Properties: %@", [inputNode properties]); + DLog(@"Input Properties: %@", [inputNode properties]); if (![converterNode setupWithInputFormat:propertiesToASBD([inputNode properties]) outputFormat:outputFormat]) return NO; - + + [self setRGInfo:rgi]; + return YES; } - (void)launchThreads { - NSLog(@"Properties: %@", [inputNode properties]); + DLog(@"Properties: %@", [inputNode properties]); [inputNode launchThread]; [converterNode launchThread]; @@ -125,7 +129,7 @@ [inputNode release]; [converterNode release]; - NSLog(@"Bufferchain dealloc"); + DLog(@"Bufferchain dealloc"); [super dealloc]; } @@ -149,13 +153,13 @@ - (void)initialBufferFilled:(id)sender { - NSLog(@"INITIAL BUFFER FILLED"); + DLog(@"INITIAL BUFFER FILLED"); [controller launchOutputThread]; } - (void)inputFormatDidChange:(AudioStreamBasicDescription)format { - NSLog(@"FORMAT DID CHANGE!"); + DLog(@"FORMAT DID CHANGE!"); } diff --git a/Audio/Chain/ConverterNode.m b/Audio/Chain/ConverterNode.m index 91e2dcbe1..8eddae539 100644 --- a/Audio/Chain/ConverterNode.m +++ b/Audio/Chain/ConverterNode.m @@ -8,22 +8,24 @@ #import "ConverterNode.h" +#import "Logging.h" + void PrintStreamDesc (AudioStreamBasicDescription *inDesc) { if (!inDesc) { - printf ("Can't print a NULL desc!\n"); + DLog (@"Can't print a NULL desc!\n"); return; } - printf ("- - - - - - - - - - - - - - - - - - - -\n"); - printf (" Sample Rate:%f\n", inDesc->mSampleRate); - printf (" Format ID:%s\n", (char*)&inDesc->mFormatID); - printf (" Format Flags:%X\n", inDesc->mFormatFlags); - printf (" Bytes per Packet:%d\n", inDesc->mBytesPerPacket); - printf (" Frames per Packet:%d\n", inDesc->mFramesPerPacket); - printf (" Bytes per Frame:%d\n", inDesc->mBytesPerFrame); - printf (" Channels per Frame:%d\n", inDesc->mChannelsPerFrame); - printf (" Bits per Channel:%d\n", inDesc->mBitsPerChannel); - printf ("- - - - - - - - - - - - - - - - - - - -\n"); + DLog (@"- - - - - - - - - - - - - - - - - - - -\n"); + DLog (@" Sample Rate:%f\n", inDesc->mSampleRate); + DLog (@" Format ID:%s\n", (char*)&inDesc->mFormatID); + DLog (@" Format Flags:%X\n", inDesc->mFormatFlags); + DLog (@" Bytes per Packet:%d\n", inDesc->mBytesPerPacket); + DLog (@" Frames per Packet:%d\n", inDesc->mFramesPerPacket); + DLog (@" Bytes per Frame:%d\n", inDesc->mBytesPerFrame); + DLog (@" Channels per Frame:%d\n", inDesc->mChannelsPerFrame); + DLog (@" Bits per Channel:%d\n", inDesc->mBitsPerChannel); + DLog (@"- - - - - - - - - - - - - - - - - - - -\n"); } @implementation ConverterNode @@ -195,7 +197,7 @@ static OSStatus ACFloatProc(AudioConverterRef inAudioConverter, UInt32* ioNumber amountRead += ioData.mBuffers[0].mDataByteSize; if (err == 100) { - NSLog(@"INSIZE: %i", amountRead); + DLog(@"INSIZE: %i", amountRead); ioData.mBuffers[0].mData = floatBuffer + amountRead; ioNumberFrames = ( amount / outputFormat.mBytesPerFrame ) - ( amountRead / floatFormat.mBytesPerFrame ); ioData.mBuffers[0].mDataByteSize = ioNumberFrames * floatFormat.mBytesPerFrame; @@ -203,7 +205,7 @@ static OSStatus ACFloatProc(AudioConverterRef inAudioConverter, UInt32* ioNumber } else if (err != noErr && err != kAudioConverterErr_InvalidInputSize) { - NSLog(@"Error: %i", err); + DLog(@"Error: %i", err); return amountRead; } @@ -229,7 +231,7 @@ tryagain2: amountRead += ioData.mBuffers[0].mDataByteSize; if (err == 100) { - NSLog(@"INSIZE: %i", amountRead); + DLog(@"INSIZE: %i", amountRead); ioData.mBuffers[0].mData = dest + amountRead; ioNumberFrames = ( amount - amountRead ) / outputFormat.mBytesPerFrame; ioData.mBuffers[0].mDataByteSize = ioNumberFrames * outputFormat.mBytesPerFrame; @@ -237,7 +239,7 @@ tryagain2: } else if (err != noErr && err != kAudioConverterErr_InvalidInputSize) { - NSLog(@"Error: %i", err); + DLog(@"Error: %i", err); } return amountRead; @@ -248,7 +250,7 @@ tryagain2: change:(NSDictionary *)change context:(void *)context { - NSLog(@"SOMETHING CHANGED!"); + DLog(@"SOMETHING CHANGED!"); if ([keyPath isEqual:@"values.volumeScaling"]) { //User reset the volume scaling option [self refreshVolumeScaling]; @@ -321,14 +323,14 @@ static float db_to_scale(float db) stat = AudioConverterNew( &inputFormat, &floatFormat, &converterFloat ); if (stat != noErr) { - NSLog(@"Error creating converter %i", stat); + ALog(@"Error creating converter %i", stat); return NO; } stat = AudioConverterNew ( &floatFormat, &outputFormat, &converter ); if (stat != noErr) { - NSLog(@"Error creating converter %i", stat); + ALog(@"Error creating converter %i", stat); return NO; } @@ -339,7 +341,7 @@ static float db_to_scale(float db) stat = AudioConverterSetProperty(converter,kAudioConverterChannelMap,sizeof(channelMap),channelMap); if (stat != noErr) { - NSLog(@"Error mapping channels %i", stat); + ALog(@"Error mapping channels %i", stat); return NO; } } @@ -350,7 +352,7 @@ static float db_to_scale(float db) stat = AudioConverterSetProperty(converter,kAudioConverterChannelMap,sizeof(channelMap),channelMap); if (stat != noErr) { - NSLog(@"Error mapping channels %i", stat); + ALog(@"Error mapping channels %i", stat); return NO; } } @@ -365,7 +367,7 @@ static float db_to_scale(float db) - (void)dealloc { - NSLog(@"Decoder dealloc"); + DLog(@"Decoder dealloc"); [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.volumeScaling"]; @@ -376,20 +378,20 @@ static float db_to_scale(float db) - (void)setOutputFormat:(AudioStreamBasicDescription)format { - NSLog(@"SETTING OUTPUT FORMAT!"); + DLog(@"SETTING OUTPUT FORMAT!"); outputFormat = format; } - (void)inputFormatDidChange:(AudioStreamBasicDescription)format { - NSLog(@"FORMAT CHANGED"); + DLog(@"FORMAT CHANGED"); [self cleanUp]; [self setupWithInputFormat:format outputFormat:outputFormat]; } - (void)setRGInfo:(NSDictionary *)rgi { - NSLog(@"Setting ReplayGain info"); + DLog(@"Setting ReplayGain info"); [rgInfo release]; [rgi retain]; rgInfo = rgi; diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index 2d7133425..e04042072 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -12,6 +12,8 @@ #import "CoreAudioUtils.h" +#import "Logging.h" + @implementation InputNode - (BOOL)openWithSource:(id)source @@ -26,7 +28,7 @@ if (![decoder open:source]) { - NSLog(@"Couldn't open decoder..."); + ALog(@"Couldn't open decoder..."); return NO; } @@ -44,7 +46,7 @@ - (BOOL)openWithDecoder:(id) d { - NSLog(@"Opening with old decoder: %@", d); + DLog(@"Opening with old decoder: %@", d); decoder = d; [decoder retain]; @@ -59,14 +61,14 @@ shouldContinue = YES; shouldSeek = NO; - NSLog(@"DONES: %@", decoder); + DLog(@"DONES: %@", decoder); return YES; } - (void)registerObservers { - NSLog(@"REGISTERING OBSERVERS"); + DLog(@"REGISTERING OBSERVERS"); [decoder addObserver:self forKeyPath:@"properties" options:(NSKeyValueObservingOptionNew) @@ -83,7 +85,7 @@ change:(NSDictionary *)change context:(void *)context { - NSLog(@"SOMETHING CHANGED!"); + DLog(@"SOMETHING CHANGED!"); if ([keyPath isEqual:@"properties"]) { //Setup converter! //Inform something of properties change @@ -106,14 +108,14 @@ { if (shouldSeek == YES) { - NSLog(@"SEEKING!"); + DLog(@"SEEKING!"); [decoder seek:seekFrame]; shouldSeek = NO; - NSLog(@"Seeked! Resetting Buffer"); + DLog(@"Seeked! Resetting Buffer"); [self resetBuffer]; - NSLog(@"Reset buffer!"); + DLog(@"Reset buffer!"); initialBufferFilled = NO; } @@ -128,10 +130,10 @@ [controller initialBufferFilled:self]; } - NSLog(@"End of stream? %@", [self properties]); + DLog(@"End of stream? %@", [self properties]); endOfStream = YES; shouldClose = [controller endOfInputReached]; //Lets us know if we should keep going or not (occassionally, for track changes within a file) - NSLog(@"closing? is %i", shouldClose); + DLog(@"closing? is %i", shouldClose); break; } @@ -149,14 +151,14 @@ { seekFrame = frame; shouldSeek = YES; - NSLog(@"Should seek!"); + DLog(@"Should seek!"); [semaphore signal]; } - (BOOL)setTrack:(NSURL *)track { if ([decoder respondsToSelector:@selector(setTrack:)] && [decoder setTrack:track]) { - NSLog(@"SET TRACK!"); + DLog(@"SET TRACK!"); return YES; } @@ -166,7 +168,7 @@ - (void)dealloc { - NSLog(@"Input Node dealloc"); + DLog(@"Input Node dealloc"); [decoder removeObserver:self forKeyPath:@"properties"]; [decoder removeObserver:self forKeyPath:@"metadata"]; diff --git a/Audio/Chain/Node.m b/Audio/Chain/Node.m index 5561abc94..2dc4951b9 100644 --- a/Audio/Chain/Node.m +++ b/Audio/Chain/Node.m @@ -8,6 +8,8 @@ #import "Node.h" +#import "Logging.h" + @implementation Node - (id)initWithController:(id)c previous:(id)p @@ -111,10 +113,10 @@ endOfStream = YES; } /* if (availInput <= 0) { - NSLog(@"BUFFER RAN DRY!"); + DLog(@"BUFFER RAN DRY!"); } else if (availInput < amount) { - NSLog(@"BUFFER IN DANGER"); + DLog(@"BUFFER IN DANGER"); } */ diff --git a/Audio/Chain/OutputNode.m b/Audio/Chain/OutputNode.m index c3f72e001..006abeb81 100644 --- a/Audio/Chain/OutputNode.m +++ b/Audio/Chain/OutputNode.m @@ -11,6 +11,8 @@ #import "AudioPlayer.h" #import "BufferChain.h" +#import "Logging.h" + @implementation OutputNode - (void)setup @@ -59,7 +61,7 @@ } /* if (n == 0) { - NSLog(@"Output Buffer dry!"); + DLog(@"Output Buffer dry!"); } */ amountPlayed += n; diff --git a/Audio/CogAudio.xcodeproj/project.pbxproj b/Audio/CogAudio.xcodeproj/project.pbxproj index 715b43a6c..f6476c18c 100644 --- a/Audio/CogAudio.xcodeproj/project.pbxproj +++ b/Audio/CogAudio.xcodeproj/project.pbxproj @@ -43,6 +43,7 @@ 17F94DD50B8D0F7000A34E87 /* PluginController.h in Headers */ = {isa = PBXBuildFile; fileRef = 17F94DD30B8D0F7000A34E87 /* PluginController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 17F94DD60B8D0F7000A34E87 /* PluginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 17F94DD40B8D0F7000A34E87 /* PluginController.m */; }; 17F94DDD0B8D101100A34E87 /* Plugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 17F94DDC0B8D101100A34E87 /* Plugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8384912718080FF100E7332D /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384912618080FF100E7332D /* Logging.h */; }; 8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; }; 8E8D3D2F0CBAEE6E00135C1B /* AudioContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E8D3D2D0CBAEE6E00135C1B /* AudioContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8E8D3D300CBAEE6E00135C1B /* AudioContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E8D3D2E0CBAEE6E00135C1B /* AudioContainer.m */; }; @@ -105,6 +106,7 @@ 17F94DD40B8D0F7000A34E87 /* PluginController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PluginController.m; sourceTree = ""; }; 17F94DDC0B8D101100A34E87 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Plugin.h; sourceTree = ""; }; 32DBCF5E0370ADEE00C91783 /* CogAudio_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CogAudio_Prefix.pch; sourceTree = ""; }; + 8384912618080FF100E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 8DC2EF5B0486A6940098B216 /* CogAudio.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CogAudio.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8E8D3D2D0CBAEE6E00135C1B /* AudioContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioContainer.h; sourceTree = ""; }; @@ -269,6 +271,7 @@ 17D21CDC0B8BE5B400D1EBDE /* Utils */ = { isa = PBXGroup; children = ( + 8384912618080FF100E7332D /* Logging.h */, 17D21CF10B8BE5EF00D1EBDE /* Semaphore.h */, 17D21CF20B8BE5EF00D1EBDE /* Semaphore.m */, ); @@ -316,6 +319,7 @@ 17B619300B909BC300BC003F /* AudioPropertiesReader.h in Headers */, 17ADB13C0B97926D00257CA2 /* AudioSource.h in Headers */, 8EC1225F0B993BD500C5B3AD /* ConverterNode.h in Headers */, + 8384912718080FF100E7332D /* Logging.h in Headers */, 8E8D3D2F0CBAEE6E00135C1B /* AudioContainer.h in Headers */, B0575F2D0D687A0800411D77 /* Helper.h in Headers */, 07DB5F3E0ED353A900C2E3EF /* AudioMetadataWriter.h in Headers */, diff --git a/Audio/Output/OutputCoreAudio.m b/Audio/Output/OutputCoreAudio.m index 9369cd8de..85ac63e19 100644 --- a/Audio/Output/OutputCoreAudio.m +++ b/Audio/Output/OutputCoreAudio.m @@ -9,6 +9,8 @@ #import "OutputCoreAudio.h" #import "OutputNode.h" +#import "Logging.h" + @implementation OutputCoreAudio - (id)initWithController:(OutputNode *)c @@ -79,7 +81,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc OSStatus err; if (outputDevice == -1) { - NSLog(@"DEVICE IS -1"); + DLog(@"DEVICE IS -1"); UInt32 size = sizeof(AudioDeviceID); AudioObjectPropertyAddress theAddress = { .mSelector = kAudioHardwarePropertyDefaultOutputDevice, @@ -89,7 +91,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &theAddress, 0, NULL, &size, &deviceID); if (err != noErr) { - NSLog(@"THERES NO DEFAULT OUTPUT DEVICE"); + ALog(@"THERES NO DEFAULT OUTPUT DEVICE"); return NO; } @@ -106,7 +108,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc sizeof(AudioDeviceID)); if (err != noErr) { - NSLog(@"THERES NO OUTPUT DEVICE!!!!!! %i", err); + ALog(@"No output device could be found, your random error code is %i. Have a nice day!", err); return NO; } diff --git a/Audio/PluginController.m b/Audio/PluginController.m index 6dab3f7f9..5f0ec6cbd 100644 --- a/Audio/PluginController.m +++ b/Audio/PluginController.m @@ -1,6 +1,8 @@ #import "PluginController.h" #import "Plugin.h" +#import "Logging.h" + @implementation PluginController @synthesize sources; @@ -66,7 +68,7 @@ static PluginController *sharedPluginController = nil; NSArray *classNames = [[notification userInfo] objectForKey:@"NSLoadedClasses"]; for (NSString *className in classNames) { - NSLog(@"Class loaded: %@", className); + DLog(@"Class loaded: %@", className); Class bundleClass = NSClassFromString(className); if ([bundleClass conformsToProtocol:@protocol(CogContainer)]) { [self setupContainer:className]; @@ -181,15 +183,15 @@ static PluginController *sharedPluginController = nil; - (void)printPluginInfo { - NSLog(@"Sources: %@", self.sources); - NSLog(@"Containers: %@", self.containers); - NSLog(@"Metadata Readers: %@", self.metadataReaders); + ALog(@"Sources: %@", self.sources); + ALog(@"Containers: %@", self.containers); + ALog(@"Metadata Readers: %@", self.metadataReaders); - NSLog(@"Properties Readers By Extension: %@", self.propertiesReadersByExtension); - NSLog(@"Properties Readers By Mime Type: %@", self.propertiesReadersByMimeType); + ALog(@"Properties Readers By Extension: %@", self.propertiesReadersByExtension); + ALog(@"Properties Readers By Mime Type: %@", self.propertiesReadersByMimeType); - NSLog(@"Decoders by Extension: %@", self.decodersByExtension); - NSLog(@"Decoders by Mime Type: %@", self.decodersByMimeType); + ALog(@"Decoders by Extension: %@", self.decodersByExtension); + ALog(@"Decoders by Mime Type: %@", self.decodersByMimeType); } - (id) audioSourceForURL:(NSURL *)url diff --git a/Audio/ThirdParty/VirtualRingBuffer/VirtualRingBuffer.m b/Audio/ThirdParty/VirtualRingBuffer/VirtualRingBuffer.m index 743874fad..421a9570c 100644 --- a/Audio/ThirdParty/VirtualRingBuffer/VirtualRingBuffer.m +++ b/Audio/ThirdParty/VirtualRingBuffer/VirtualRingBuffer.m @@ -20,6 +20,7 @@ #include #include +#import "Logging.h" @implementation VirtualRingBuffer @@ -235,9 +236,7 @@ void *allocateVirtualBuffer(UInt32 bufferLength) return NULL; } if (realAddress != originalAddress) { -#if DEBUG - NSLog(@"allocateVirtualBuffer: vm_allocate 2nd time didn't return same address (%p vs %p)", originalAddress, realAddress); -#endif + DLog(@"allocateVirtualBuffer: vm_allocate 2nd time didn't return same address (%p vs %p)", (void *) originalAddress, (void *) realAddress); goto errorReturn; } @@ -251,15 +250,11 @@ void *allocateVirtualBuffer(UInt32 bufferLength) goto errorReturn; } if (!memoryEntry) { -#if DEBUG - NSLog(@"mach_make_memory_entry: returned memoryEntry of NULL"); -#endif + DLog(@"mach_make_memory_entry: returned memoryEntry of NULL"); goto errorReturn; } if (memoryEntryLength != bufferLength) { -#if DEBUG - NSLog(@"mach_make_memory_entry: size changed (from %0x to %0x)", bufferLength, memoryEntryLength); -#endif + DLog(@"mach_make_memory_entry: size changed (from %0x to %0lx)", bufferLength, memoryEntryLength); goto errorReturn; } @@ -276,9 +271,7 @@ void *allocateVirtualBuffer(UInt32 bufferLength) goto errorReturn; } if (virtualAddress != realAddress + bufferLength) { -#if DEBUG - NSLog(@"vm_map: didn't return correct address (%p vs %p)", realAddress + bufferLength, virtualAddress); -#endif + DLog(@"vm_map: didn't return correct address (%p vs %p)", (void *) realAddress + bufferLength, (void *) virtualAddress); goto errorReturn; } diff --git a/AudioScrobbler/AudioScrobbler.m b/AudioScrobbler/AudioScrobbler.m index eaaa3273e..c2129aab2 100644 --- a/AudioScrobbler/AudioScrobbler.m +++ b/AudioScrobbler/AudioScrobbler.m @@ -23,6 +23,8 @@ #import "AudioScrobblerClient.h" #import "PlaylistEntry.h" +#import "Logging.h" + // ======================================== // Symbolic Constants // ======================================== @@ -79,7 +81,7 @@ escapeForLastFM(NSString *string) kern_return_t result = semaphore_create(mach_task_self(), &_semaphore, SYNC_POLICY_FIFO, 0); if(KERN_SUCCESS != result) { - NSLog(@"Couldn't create semaphore (%s).", mach_error_type(result)); + ALog(@"Couldn't create semaphore (%s).", mach_error_type(result)); [self release]; return nil; @@ -219,7 +221,7 @@ escapeForLastFM(NSString *string) response = [client receive]; if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)]) - NSLog(@"AudioScrobbler error: %@", response); + ALog(@"AudioScrobbler error: %@", response); [client shutdown]; } @@ -227,7 +229,7 @@ escapeForLastFM(NSString *string) @catch(NSException *exception) { [client shutdown]; -// NSLog(@"Exception: %@",exception); +// ALog(@"Exception: %@",exception); [pool release]; continue; } @@ -244,7 +246,7 @@ escapeForLastFM(NSString *string) response = [client receive]; if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)]) - NSLog(@"AudioScrobbler error: %@", response); + ALog(@"AudioScrobbler error: %@", response); [client shutdown]; } diff --git a/AudioScrobbler/AudioScrobblerClient.m b/AudioScrobbler/AudioScrobblerClient.m index 44724af38..7c0814b3e 100644 --- a/AudioScrobbler/AudioScrobblerClient.m +++ b/AudioScrobbler/AudioScrobblerClient.m @@ -27,6 +27,8 @@ #include +#import "Logging.h" + #define kBufferSize 1024 #define kPortsToStep 5 @@ -43,7 +45,7 @@ addressForHost(NSString *hostname) if(INADDR_NONE == address) { hostinfo = gethostbyname([hostname cStringUsingEncoding:NSASCIIStringEncoding]); if(NULL == hostinfo) { - NSLog(@"AudioScrobblerClient error: Unable to resolve address for \"%@\".", hostname); + ALog(@"AudioScrobblerClient error: Unable to resolve address for \"%@\".", hostname); return INADDR_NONE; } @@ -99,7 +101,7 @@ addressForHost(NSString *hostname) ssize_t bytesSent = 0; if(NO == [self isConnected]) { - NSLog(@"AudioScrobblerClient error: Can't send data, client not connected"); + ALog(@"AudioScrobblerClient error: Can't send data, client not connected"); return; } @@ -107,7 +109,7 @@ addressForHost(NSString *hostname) bytesSent = send(_socket, utf8data + totalBytesSent, bytesToSend - totalBytesSent, 0); if(-1 == bytesSent || 0 == bytesSent) - NSLog(@"AudioScrobblerClient error: Unable to send data through socket: %s", strerror(errno)); + ALog(@"AudioScrobblerClient error: Unable to send data through socket: %s", strerror(errno)); totalBytesSent += bytesSent; } @@ -122,14 +124,14 @@ addressForHost(NSString *hostname) NSString *result = nil; if(NO == [self isConnected]) { - NSLog(@"AudioScrobblerClient error: Can't receive data, client not connected"); + ALog(@"AudioScrobblerClient error: Can't receive data, client not connected"); return nil; } do { bytesRead = recv(_socket, buffer, readSize, 0); if(-1 == bytesRead || 0 == bytesRead) { - NSLog(@"AudioScrobblerClient error: Unable to receive data through socket: %s", strerror(errno)); + ALog(@"AudioScrobblerClient error: Unable to receive data through socket: %s", strerror(errno)); break; } @@ -158,16 +160,16 @@ addressForHost(NSString *hostname) result = shutdown(_socket, SHUT_WR); if(-1 == result) - NSLog(@"AudioScrobblerClient error: Socket shutdown failed: %s", strerror(errno)); + ALog(@"AudioScrobblerClient error: Socket shutdown failed: %s", strerror(errno)); for(;;) { bytesRead = recv(_socket, buffer, kBufferSize, 0); if(-1 == bytesRead) - NSLog(@"AudioScrobblerClient error: Waiting for shutdown confirmation failed: %s", strerror(errno)); + ALog(@"AudioScrobblerClient error: Waiting for shutdown confirmation failed: %s", strerror(errno)); if(0 != bytesRead) { NSString *received = [[NSString alloc] initWithBytes:buffer length:bytesRead encoding:NSUTF8StringEncoding]; - NSLog(@"Received unexpected bytes during shutdown: %@", received); + ALog(@"Received unexpected bytes during shutdown: %@", received); [received release]; } else @@ -176,7 +178,7 @@ addressForHost(NSString *hostname) result = close(_socket); if(-1 == result) - NSLog(@"Couldn't close socket (%s)", strerror(errno)); + ALog(@"Couldn't close socket (%s)", strerror(errno)); _socket = -1; _port = 0; @@ -198,7 +200,7 @@ addressForHost(NSString *hostname) _socket = socket(AF_INET, SOCK_STREAM, 0); if(-1 == _socket) { - NSLog(@"Unable to create socket (%s)", strerror(errno)); + ALog(@"Unable to create socket (%s)", strerror(errno)); return NO; } diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index bcc9ae7a4..c9068cd29 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -745,6 +745,7 @@ 8384911F1807F38A00E7332D /* NowPlayingBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NowPlayingBarController.m; path = Window/NowPlayingBarController.m; sourceTree = ""; }; 838491201807F38A00E7332D /* NowPlayingBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NowPlayingBarController.h; path = Window/NowPlayingBarController.h; sourceTree = ""; }; 838491241807F75D00E7332D /* NowPlayingBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NowPlayingBarView.h; path = Window/NowPlayingBarView.h; sourceTree = ""; }; + 8384912518080F2D00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = ""; }; 8399D4E01805A55000B503B1 /* XmlContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XmlContainer.m; sourceTree = ""; }; 8399D4E11805A55000B503B1 /* XmlContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XmlContainer.h; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; @@ -937,6 +938,7 @@ 177EC0110B8BC2CF0000BC8C /* Utils */ = { isa = PBXGroup; children = ( + 8384912518080F2D00E7332D /* Logging.h */, 177EC01A0B8BC2CF0000BC8C /* TrackingCell.h */, 177EC01B0B8BC2CF0000BC8C /* TrackingCell.m */, 177EC01C0B8BC2CF0000BC8C /* TrackingSlider.h */, diff --git a/Feedback/FeedbackController.m b/Feedback/FeedbackController.m index b6a6e8674..db751191f 100644 --- a/Feedback/FeedbackController.m +++ b/Feedback/FeedbackController.m @@ -8,6 +8,7 @@ #import "FeedbackController.h" +#import "Logging.h" @implementation FeedbackController @@ -35,7 +36,7 @@ - (void)feedbackDidNotSend:(FeedbackSocket *)feedback { - NSLog(@"Error sending feedback"); + ALog(@"Error sending feedback"); [sendingIndicator stopAnimation:self]; diff --git a/Feedback/FeedbackSocket.m b/Feedback/FeedbackSocket.m index 3dec96d32..edc403143 100644 --- a/Feedback/FeedbackSocket.m +++ b/Feedback/FeedbackSocket.m @@ -8,6 +8,8 @@ #import "FeedbackSocket.h" +#import "Logging.h" + @implementation FeedbackSocket NSString *encodeForURL(NSString *s) @@ -39,7 +41,7 @@ NSString *encodeForURL(NSString *s) NSURLResponse* response; NSData* resultData = [NSURLConnection sendSynchronousRequest:post returningResponse:&response error:&error]; NSString *resultString = [[[NSString alloc] initWithData:resultData encoding:NSASCIIStringEncoding] autorelease]; - //NSLog(@"RESULT: %@", resultString); + //DLog(@"RESULT: %@", resultString); if ([resultString caseInsensitiveCompare:@"SUCCESS"] == NSOrderedSame) { [self performSelectorOnMainThread:@selector(returnSuccess:) withObject:nil waitUntilDone:NO]; diff --git a/FileTree/ContainerNode.m b/FileTree/ContainerNode.m index 4d03bed5d..0dd5a919f 100644 --- a/FileTree/ContainerNode.m +++ b/FileTree/ContainerNode.m @@ -11,6 +11,8 @@ #import "ContainedNode.h" +#import "Logging.h" + @implementation ContainerNode - (BOOL)isLeaf @@ -26,7 +28,7 @@ for (NSURL *u in urls) { ContainedNode *node = [[ContainedNode alloc] initWithDataSource:dataSource url:u]; - NSLog(@"Node: %@", u); + DLog(@"Node: %@", u); [paths addObject:node]; [node release]; } diff --git a/FileTree/FileTreeDataSource.m b/FileTree/FileTreeDataSource.m index 7b5d2ef4d..71d34df1b 100644 --- a/FileTree/FileTreeDataSource.m +++ b/FileTree/FileTreeDataSource.m @@ -13,6 +13,8 @@ #import "DirectoryNode.h" #import "PathWatcher.h" +#import "Logging.h" + @implementation FileTreeDataSource + (void)initialize @@ -39,7 +41,7 @@ change:(NSDictionary *)change context:(void *)context { - NSLog(@"File tree root URL: %@\n", [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileTreeRootURL"]); + DLog(@"File tree root URL: %@\n", [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileTreeRootURL"]); if ([keyPath isEqualToString:@"values.fileTreeRootURL"]) { [self setRootURL:[NSURL URLWithString:[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileTreeRootURL"]]]; } @@ -84,10 +86,10 @@ range:NSMakeRange(0, [path length]) ] stringByStandardizingPath]; PathNode *node = rootNode; - NSLog(@"Root | Relative | Path: %@ | %@ | %@",[[self rootURL] path], relativePath, path); + DLog(@"Root | Relative | Path: %@ | %@ | %@",[[self rootURL] path], relativePath, path); for (NSString *c in [relativePath pathComponents]) { - NSLog(@"COMPONENT: %@", c); + DLog(@"COMPONENT: %@", c); BOOL found = NO; for (PathNode *subnode in [node subpaths]) { if ([[[[subnode URL] path] lastPathComponent] isEqualToString:c]) { @@ -98,7 +100,7 @@ if (!found) { - NSLog(@"Not found!"); + DLog(@"Not found!"); return nil; } } @@ -108,10 +110,10 @@ - (void)pathDidChange:(NSString *)path { - NSLog(@"PATH DID CHANGE: %@", path); + DLog(@"PATH DID CHANGE: %@", path); //Need to find the corresponding node...and call [node reloadPath], then [self reloadPathNode:node] PathNode *node = [self nodeForPath:path]; - NSLog(@"NODE IS: %@", node); + DLog(@"NODE IS: %@", node); [node updatePath]; [self reloadPathNode:node]; } @@ -155,7 +157,7 @@ [urls addObject:[p URL]]; [paths addObject:[[p URL] path]]; } - NSLog(@"Paths: %@", paths); + DLog(@"Paths: %@", paths); [pboard declareTypes:[NSArray arrayWithObjects:CogUrlsPboardType,nil] owner:nil]; //add it to pboard [pboard setData:[NSArchiver archivedDataWithRootObject:urls] forType:CogUrlsPboardType]; [pboard addTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:self]; diff --git a/FileTree/PathNode.m b/FileTree/PathNode.m index 0c95a35e6..54b1943b2 100644 --- a/FileTree/PathNode.m +++ b/FileTree/PathNode.m @@ -17,6 +17,8 @@ #import "SmartFolderNode.h" #import "ContainerNode.h" +#import "Logging.h" + @implementation PathNode //From http://developer.apple.com/documentation/Cocoa/Conceptual/LowLevelFileMgmt/Tasks/ResolvingAliases.html @@ -33,13 +35,13 @@ NSURL *resolveAliases(NSURL *url) if (resolvedUrl != NULL) { - //NSLog(@"Resolved..."); + //DLog(@"Resolved..."); return [(NSURL *)resolvedUrl autorelease]; } } } - //NSLog(@"Not resolved"); + //DLog(@"Not resolved"); return url; } @@ -101,15 +103,15 @@ NSURL *resolveAliases(NSURL *url) PathNode *newNode; - //NSLog(@"Before: %@", u); + //DLog(@"Before: %@", u); u = resolveAliases(u); - //NSLog(@"After: %@", u); + //DLog(@"After: %@", u); BOOL isDir; if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame) { - NSLog(@"Smart folder!"); + DLog(@"Smart folder!"); newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource url:u]; isDir = NO; } diff --git a/FileTree/SmartFolderNode.m b/FileTree/SmartFolderNode.m index 2d6abbf8d..1879b9dca 100644 --- a/FileTree/SmartFolderNode.m +++ b/FileTree/SmartFolderNode.m @@ -11,6 +11,8 @@ #import "FileNode.h" #import "FileTreeDataSource.h" +#import "Logging.h" + @implementation SmartFolderNode - (BOOL)isLeaf @@ -32,7 +34,7 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query]; - NSLog(@"Making query!"); + DLog(@"Making query!"); MDQueryExecute(query, kMDQueryWantsUpdates); //Note: This is asynchronous! @@ -57,7 +59,7 @@ - (void)queryFinished:(NSNotification *)notification { - NSLog(@"Query finished!"); + DLog(@"Query finished!"); MDQueryRef query = (MDQueryRef)[notification object]; NSMutableArray *results = [NSMutableArray array]; @@ -79,7 +81,7 @@ MDQueryEnableUpdates(query); - NSLog(@"Query update!"); + DLog(@"Query update!"); [self processPaths:[results sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]]; @@ -88,7 +90,7 @@ - (void)queryUpdate:(NSNotification *)notification { - NSLog(@"Query update!"); + DLog(@"Query update!"); [self queryFinished: notification]; } diff --git a/Playlist/DNDArrayController.m b/Playlist/DNDArrayController.m index 705343065..522093187 100755 --- a/Playlist/DNDArrayController.m +++ b/Playlist/DNDArrayController.m @@ -1,6 +1,8 @@ #import "DNDArrayController.h" +#import "Logging.h" + @implementation DNDArrayController NSString *MovedRowsType = @"MOVED_ROWS_TYPE"; @@ -18,7 +20,7 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E"; - (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard { - NSLog(@"INDEX SET ON DRAG: %@", rowIndexes); + DLog(@"INDEX SET ON DRAG: %@", rowIndexes); NSData *data = [NSArchiver archivedDataWithRootObject:rowIndexes]; @@ -39,7 +41,7 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E"; if ([info draggingSource] == tv) dragOp = NSDragOperationMove; - NSLog(@"VALIDATING DROP!"); + DLog(@"VALIDATING DROP!"); // we want to put the object at, not over, // the current row (contrast NSTableViewDropOn) [tv setDropRow:row dropOperation:NSTableViewDropAbove]; @@ -64,17 +66,17 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E"; NSIndexSet *indexSet = [NSUnarchiver unarchiveObjectWithData:[[info draggingPasteboard] dataForType:MovedRowsType]]; if (indexSet) { - NSLog(@"INDEX SET ON DROP: %@", indexSet); + DLog(@"INDEX SET ON DROP: %@", indexSet); NSArray *selected = [[self arrangedObjects] objectsAtIndexes:indexSet]; [self moveObjectsInArrangedObjectsFromIndexes:indexSet toIndex:row]; [self setSelectedObjects:selected]; - NSLog(@"ACCEPTING DROP!"); + DLog(@"ACCEPTING DROP!"); return YES; } } - NSLog(@"REJECTING DROP!"); + DLog(@"REJECTING DROP!"); return NO; } diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index fd5a98a07..61a070fae 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -21,6 +21,8 @@ #import "CogAudio/AudioPlayer.h" +#import "Logging.h" + @implementation PlaylistController @synthesize currentEntry; @@ -163,7 +165,7 @@ - (NSString *)tableView:(NSTableView *)tv toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc row:(int)row mouseLocation:(NSPoint)mouseLocation { - NSLog(@"GETTING STATUS FOR ROW: %i: %@!", row, [[[self arrangedObjects] objectAtIndex:row] statusMessage]); + DLog(@"GETTING STATUS FOR ROW: %i: %@!", row, [[[self arrangedObjects] objectAtIndex:row] statusMessage]); return [[[self arrangedObjects] objectAtIndex:row] statusMessage]; } @@ -228,7 +230,7 @@ // Get files from an file drawer drop if ([bestType isEqualToString:CogUrlsPboardType]) { NSArray *urls = [NSUnarchiver unarchiveObjectWithData:[[info draggingPasteboard] dataForType:CogUrlsPboardType]]; - NSLog(@"URLS: %@", urls); + DLog(@"URLS: %@", urls); //[playlistLoader insertURLs: urls atIndex:row sort:YES]; [acceptedURLs addObjectsFromArray:urls]; } @@ -299,24 +301,24 @@ - (void)removeObjectsAtArrangedObjectIndexes:(NSIndexSet *)indexes { - NSLog(@"Removing indexes: %@", indexes); - NSLog(@"Current index: %i", currentEntry.index); + DLog(@"Removing indexes: %@", indexes); + DLog(@"Current index: %i", currentEntry.index); if (currentEntry.index >= 0 && [indexes containsIndex:currentEntry.index]) { currentEntry.index = -currentEntry.index - 1; - NSLog(@"Current removed: %i", currentEntry.index); + DLog(@"Current removed: %i", currentEntry.index); } if (currentEntry.index < 0) //Need to update the negative index { int i = -currentEntry.index - 1; - NSLog(@"I is %i", i); + DLog(@"I is %i", i); int j; for (j = i - 1; j >= 0; j--) { if ([indexes containsIndex:j]) { - NSLog(@"Removing 1"); + DLog(@"Removing 1"); i--; } } @@ -334,7 +336,7 @@ - (void)setSortDescriptors:(NSArray *)sortDescriptors { - NSLog(@"Current: %@, setting: %@", [self sortDescriptors], sortDescriptors); + DLog(@"Current: %@, setting: %@", [self sortDescriptors], sortDescriptors); //Cheap hack so the index column isn't sorted if (([sortDescriptors count] != 0) && [[[sortDescriptors objectAtIndex:0] key] caseInsensitiveCompare:@"index"] == NSOrderedSame) @@ -758,7 +760,7 @@ [queueList addObject:queueItem]; } - NSLog(@"TOGGLE QUEUED: %i", queueItem.queued); + DLog(@"TOGGLE QUEUED: %i", queueItem.queued); } int i = 0; diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index a776480a2..20bead0d3 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -25,6 +25,8 @@ #import "NSData+MD5.h" +#import "Logging.h" + @implementation PlaylistLoader - (id)init @@ -115,7 +117,7 @@ { NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filename createFile:YES]; if (!fileHandle) { - NSLog(@"Error saving m3u!"); + ALog(@"Error saving m3u!"); return NO; } [fileHandle truncateFileAtOffset:0]; @@ -318,7 +320,7 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL } } - NSLog(@"Expanded urls: %@", expandedURLs); + DLog(@"Expanded urls: %@", expandedURLs); NSArray *sortedURLs; if (sort == YES) @@ -350,9 +352,9 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL } } - NSLog(@"File urls: %@", fileURLs); + DLog(@"File urls: %@", fileURLs); - NSLog(@"Contained urls: %@", containedURLs); + DLog(@"Contained urls: %@", containedURLs); for (url in fileURLs) { @@ -371,7 +373,7 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL } } - NSLog(@"Valid urls: %@", validURLs); + DLog(@"Valid urls: %@", validURLs); for (url in containedURLs) { diff --git a/Playlist/ToggleQueueTitleTransformer.m b/Playlist/ToggleQueueTitleTransformer.m index e60274050..be985a97e 100644 --- a/Playlist/ToggleQueueTitleTransformer.m +++ b/Playlist/ToggleQueueTitleTransformer.m @@ -8,6 +8,7 @@ #import "ToggleQueueTitleTransformer.h" +#import "Logging.h" @implementation ToggleQueueTitleTransformer @@ -17,7 +18,7 @@ // Convert from NSNumber to NSString - (id)transformedValue:(id)value { - NSLog(@"VALUE: %@", value); + DLog(@"VALUE: %@", value); if (value == nil) return nil; BOOL queued = [value boolValue]; diff --git a/Playlist/XmlContainer.m b/Playlist/XmlContainer.m index e7e325020..3e01b6e16 100644 --- a/Playlist/XmlContainer.m +++ b/Playlist/XmlContainer.m @@ -10,6 +10,8 @@ #import +#import "Logging.h" + @implementation XmlContainer + (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename @@ -37,7 +39,7 @@ break; } } - NSLog(@"Fragment: %@", fragment); + DLog(@"Fragment: %@", fragment); if (![unixPath hasPrefix:@"/"]) { //Only relative paths would have windows backslashes. @@ -72,7 +74,7 @@ NSPropertyListFormat format; id plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; if(!plist){ - NSLog(@"Error: %@",error); + ALog(@"Error: %@",error); [error release]; return nil; } diff --git a/Plugins/APL/APL.xcodeproj/project.pbxproj b/Plugins/APL/APL.xcodeproj/project.pbxproj index 8196455d4..08391d1c2 100644 --- a/Plugins/APL/APL.xcodeproj/project.pbxproj +++ b/Plugins/APL/APL.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* APL_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APL_Prefix.pch; sourceTree = ""; }; + 838491281808135500E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8E8D42350CBB0F9800135C1B /* APLDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APLDecoder.h; sourceTree = ""; }; 8E8D42360CBB0F9800135C1B /* APLDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APLDecoder.m; sourceTree = ""; }; @@ -71,6 +72,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 838491281808135500E7332D /* Logging.h */, 8E8D423C0CBB0FF600135C1B /* Plugin.h */, 8E8D42350CBB0F9800135C1B /* APLDecoder.h */, 8E8D42360CBB0F9800135C1B /* APLDecoder.m */, diff --git a/Plugins/APL/APLDecoder.m b/Plugins/APL/APLDecoder.m index 5b5982a53..ba4a3adc0 100644 --- a/Plugins/APL/APLDecoder.m +++ b/Plugins/APL/APLDecoder.m @@ -1,6 +1,8 @@ #import "APLDecoder.h" #import "APLFile.h" +#import "Logging.h" + @implementation APLDecoder + (NSArray *)fileTypes { @@ -21,7 +23,7 @@ - (BOOL)open:(id)s { - //NSLog(@"Loading apl..."); + //DLog(@"Loading apl..."); if (![[s url] isFileURL]) return NO; @@ -36,14 +38,14 @@ [source retain]; if (![source open:[apl file]]) { - NSLog(@"Could not open source for file '%@' referenced in apl", [apl file]); + ALog(@"Could not open source for file '%@' referenced in apl", [apl file]); return NO; } decoder = [NSClassFromString(@"AudioDecoder") audioDecoderForSource:source]; [decoder retain]; if (![decoder open:source]) { - NSLog(@"Could not open decoder for source for apl"); + ALog(@"Could not open decoder for source for apl"); return NO; } @@ -109,7 +111,7 @@ frames = trackEnd - framePosition; if (!frames) { - NSLog(@"APL readAudio Returning 0"); + DLog(@"APL readAudio Returning 0"); return 0; } diff --git a/Plugins/APL/APLFile.m b/Plugins/APL/APLFile.m index 58a68f454..b4e87c01f 100644 --- a/Plugins/APL/APLFile.m +++ b/Plugins/APL/APLFile.m @@ -2,6 +2,8 @@ #import "APLFile.h" +#import "Logging.h" + @implementation APLFile +createWithFile:(NSString*)f { return [[APLFile alloc] initWithFile:f]; } @@ -48,18 +50,18 @@ //startBlock must be always >= 0 NSFileHandle* f = (NSFileHandle*)[NSFileHandle fileHandleForReadingAtPath:filename]; if(!f){ - NSLog(@"Failed to open apl file '%@' for reading", f); + ALog(@"Failed to open apl file '%@' for reading", f); return nil; } NSString* header = @"[Monkey's Audio Image Link File]\r\n"; NSData* da = [f readDataOfLength:[header length]]; if (!da) { - NSLog(@"Cannot read header"); + ALog(@"Cannot read header"); return nil; } NSString* str = [[[NSString alloc] autorelease] initWithData:da encoding: NSASCIIStringEncoding]; if([str compare:header options:NSCaseInsensitiveSearch]) { - NSLog(@"APL header mismatch"); + ALog(@"APL header mismatch"); return nil; } //now read by lines, skip empty, up to line (or any starting with '-' - may be other tags can be present) @@ -79,19 +81,19 @@ { [file release]; file = [self urlForPath:value relativeTo:filename]; - NSLog(@"APL refers to file '%@' read '%@'", file, value); + DLog(@"APL refers to file '%@' read '%@'", file, value); continue; } if (![field compare:@"Start Block" options:NSCaseInsensitiveSearch]) { startBlock = [value intValue]; //!!! bugs with files over 2GB - //NSLog(@"APL start block %d (%@)", startBlock, value); + //DLog(@"APL start block %d (%@)", startBlock, value); continue; } if (![field compare:@"Finish Block" options:NSCaseInsensitiveSearch]) { endBlock = [value intValue]; //!!! bugs with files over 2GB - //NSLog(@"APL start block %d (%@)", endBlock, value); + //DLog(@"APL start block %d (%@)", endBlock, value); continue; } } diff --git a/Plugins/ArchiveSource/ArchiveSource.xcodeproj/project.pbxproj b/Plugins/ArchiveSource/ArchiveSource.xcodeproj/project.pbxproj index ac35cc695..8d78aaa92 100644 --- a/Plugins/ArchiveSource/ArchiveSource.xcodeproj/project.pbxproj +++ b/Plugins/ArchiveSource/ArchiveSource.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ 8359FF2417FEF35C0060F3ED /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 8359FF2617FEF35C0060F3ED /* ArchiveSource-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArchiveSource-Prefix.pch"; sourceTree = ""; }; 8359FF6A17FEF39F0060F3ED /* File_Extractor.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = File_Extractor.xcodeproj; path = ../../Frameworks/File_Extractor/File_Extractor.xcodeproj; sourceTree = ""; }; + 8384913518081BA000E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -115,6 +116,7 @@ 8359FF2017FEF35C0060F3ED /* ArchiveSource */ = { isa = PBXGroup; children = ( + 8384913518081BA000E7332D /* Logging.h */, 835900A017FF079C0060F3ED /* Plugin.h */, 8359009A17FEFDA80060F3ED /* ArchiveContainer.h */, 8359009B17FEFDA80060F3ED /* ArchiveContainer.m */, diff --git a/Plugins/ArchiveSource/ArchiveSource/ArchiveContainer.m b/Plugins/ArchiveSource/ArchiveSource/ArchiveContainer.m index 2ae24806b..60bf6ff4c 100644 --- a/Plugins/ArchiveSource/ArchiveSource/ArchiveContainer.m +++ b/Plugins/ArchiveSource/ArchiveSource/ArchiveContainer.m @@ -10,6 +10,8 @@ #import +#import "Logging.h" + static NSString * path_pack_string(NSString * src) { return [NSString stringWithFormat:@"|%lu|%@|", [src length], src]; @@ -46,7 +48,7 @@ static NSString * g_make_unpack_path(NSString * archive, NSString * file, NSStri fex_t * fex; fex_err_t error = fex_open( &fex, [[url path] UTF8String] ); if ( error ) { - NSLog(@"Archive error: %s", error); + ALog(@"Archive error: %s", error); return [NSArray array]; } diff --git a/Plugins/ArchiveSource/ArchiveSource/ArchiveSource.m b/Plugins/ArchiveSource/ArchiveSource/ArchiveSource.m index d0be84666..e62c6c225 100644 --- a/Plugins/ArchiveSource/ArchiveSource/ArchiveSource.m +++ b/Plugins/ArchiveSource/ArchiveSource/ArchiveSource.m @@ -8,6 +8,7 @@ #import "ArchiveSource.h" +#import "Logging.h" static NSString * path_unpack_string(NSString * src, NSRange * remainder) { @@ -88,7 +89,7 @@ static BOOL g_parse_unpack_path(NSString * src, NSString ** archive, NSString ** error = fex_open( &fex, [archive UTF8String] ); if ( error ) { - NSLog(@"Error opening archive: %s", error); + ALog(@"Error opening archive: %s", error); return NO; } @@ -103,7 +104,7 @@ static BOOL g_parse_unpack_path(NSString * src, NSString ** archive, NSString ** error = fex_data( fex, &data ); if ( error ) { - NSLog(@"Error unpacking file from archive: %s", error); + ALog(@"Error unpacking file from archive: %s", error); return NO; } diff --git a/Plugins/CoreAudio/CoreAudio.xcodeproj/project.pbxproj b/Plugins/CoreAudio/CoreAudio.xcodeproj/project.pbxproj index c39675ceb..e710151ea 100644 --- a/Plugins/CoreAudio/CoreAudio.xcodeproj/project.pbxproj +++ b/Plugins/CoreAudio/CoreAudio.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 17C93EAB0B8FF3CE008627D6 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = ""; }; 17C93EB20B8FF3E1008627D6 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* CoreAudio_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreAudio_Prefix.pch; sourceTree = ""; }; + 83849129180813E800E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* CoreAudio.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreAudio.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -74,6 +75,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83849129180813E800E7332D /* Logging.h */, 177FCFCA0B90C9A10011C3B5 /* Plugin.h */, 17C93E720B8FF192008627D6 /* CoreAudioDecoder.h */, 17C93E730B8FF192008627D6 /* CoreAudioDecoder.m */, diff --git a/Plugins/CoreAudio/CoreAudioDecoder.m b/Plugins/CoreAudio/CoreAudioDecoder.m index 8b25dcd9f..3653e7de7 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.m +++ b/Plugins/CoreAudio/CoreAudioDecoder.m @@ -22,6 +22,8 @@ #import "CoreAudioDecoder.h" +#import "Logging.h" + @interface CoreAudioDecoder (Private) - (BOOL) readInfoFromExtAudioFileRef; @end @@ -34,7 +36,7 @@ err = ExtAudioFileDispose(_in); if(noErr != err) { - NSLog(@"Error closing ExtAudioFile"); + DLog(@"Error closing ExtAudioFile"); } } @@ -47,7 +49,7 @@ err = ExtAudioFileOpenURL((CFURLRef)url, &_in); if(noErr != err) { - NSLog(@"Error opening file: %d", err); + ALog(@"Error opening file: %d", err); return NO; } diff --git a/Plugins/CueSheet/CueSheet.m b/Plugins/CueSheet/CueSheet.m index aa9581ab5..e11b66970 100644 --- a/Plugins/CueSheet/CueSheet.m +++ b/Plugins/CueSheet/CueSheet.m @@ -11,6 +11,8 @@ #import "Plugin.h" +#import "Logging.h" + @implementation CueSheet + (id)cueSheetWithFile:(NSString *)filename @@ -80,7 +82,7 @@ contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error]; } if (error || !contents) { - NSLog(@"Could not open file...%@ %@ %@", filename, contents, error); + ALog(@"Could not open file...%@ %@ %@", filename, contents, error); return; } @@ -219,16 +221,16 @@ if ([type isEqualToString:@"GENRE"]) { - //NSLog(@"GENRE!"); + //DLog(@"GENRE!"); if ([scanner scanString:@"\"" intoString:nil]) { - //NSLog(@"QUOTED"); + //DLog(@"QUOTED"); if (![scanner scanUpToString:@"\"" intoString:&genre]) { - NSLog(@"FAILED TO SCAN"); + DLog(@"FAILED TO SCAN"); continue; } } else { - //NSLog(@"UNQUOTED"); + //DLog(@"UNQUOTED"); if ( ![scanner scanUpToCharactersFromSet:whitespace intoString:&genre]) { continue; } @@ -236,7 +238,7 @@ } else if ([type isEqualToString:@"DATE"]) { - //NSLog(@"DATE!"); + //DLog(@"DATE!"); if ( ![scanner scanUpToCharactersFromSet:whitespace intoString:&year]) { continue; } diff --git a/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj b/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj index c5230a4e9..e9fd92898 100644 --- a/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj +++ b/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 17DA346C0CC04FCD0003F6B2 /* CueSheetMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheetMetadataReader.h; sourceTree = ""; }; 17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CueSheetMetadataReader.m; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* CueSheet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheet_Prefix.pch; sourceTree = ""; }; + 8384912A180814D900E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* CueSheet.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CueSheet.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8E8D42240CBB0F5800135C1B /* CueSheetContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheetContainer.h; sourceTree = ""; }; @@ -83,6 +84,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384912A180814D900E7332D /* Logging.h */, 8E8D423C0CBB0FF600135C1B /* Plugin.h */, 8E8D42240CBB0F5800135C1B /* CueSheetContainer.h */, 8E8D42250CBB0F5800135C1B /* CueSheetContainer.m */, diff --git a/Plugins/CueSheet/CueSheetDecoder.m b/Plugins/CueSheet/CueSheetDecoder.m index 6d281484d..0df2ff463 100644 --- a/Plugins/CueSheet/CueSheetDecoder.m +++ b/Plugins/CueSheet/CueSheetDecoder.m @@ -12,6 +12,8 @@ #import "CueSheetTrack.h" #import "CueSheetContainer.h" +#import "Logging.h" + @implementation CueSheetDecoder + (NSArray *)fileTypes @@ -59,7 +61,7 @@ [source retain]; if (![source open:[track url]]) { - NSLog(@"Could not open cuesheet source"); + ALog(@"Could not open cuesheet source"); return NO; } @@ -67,7 +69,7 @@ [decoder retain]; if (![decoder open:source]) { - NSLog(@"Could not open cuesheet decoder"); + ALog(@"Could not open cuesheet decoder"); return NO; } @@ -155,7 +157,7 @@ trackEnd = [[[decoder properties] objectForKey:@"totalFrames"] longValue]; } - NSLog(@"CHANGING TRACK!"); + DLog(@"CHANGING TRACK!"); return YES; } } @@ -186,7 +188,7 @@ if (!frames) { - NSLog(@"Returning 0"); + DLog(@"Returning 0"); return 0; } diff --git a/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj b/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj index 79a83fc2e..48438de2f 100644 --- a/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj +++ b/Plugins/Dumb/Dumb.xcodeproj/project.pbxproj @@ -78,6 +78,7 @@ 8337AAEF17FFA2D30081AFF8 /* j2b.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = j2b.c; sourceTree = ""; }; 8337AAF017FFA2D30081AFF8 /* j2b.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = j2b.h; sourceTree = ""; }; 8337AAF217FFA7640081AFF8 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + 8384912B1808155E00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Dumb.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Dumb.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -132,6 +133,7 @@ isa = PBXGroup; children = ( 8337AAE317FFA0000081AFF8 /* archive */, + 8384912B1808155E00E7332D /* Logging.h */, 8335FF6517FF6FD9002D8DD2 /* DumbContainer.h */, 8335FF6617FF6FD9002D8DD2 /* DumbContainer.m */, 17C8F70C0CBEEC87008D969D /* Plugin.h */, diff --git a/Plugins/Dumb/DumbContainer.m b/Plugins/Dumb/DumbContainer.m index e98ea2104..5d5f70a55 100755 --- a/Plugins/Dumb/DumbContainer.m +++ b/Plugins/Dumb/DumbContainer.m @@ -11,6 +11,8 @@ #import "DumbContainer.h" #import "DumbDecoder.h" +#import "Logging.h" + @implementation DumbContainer + (NSArray *)fileTypes @@ -59,7 +61,7 @@ int scanCallback(void *data, int startOrder, long length) DUMBFILE * df = dumbfile_open_memory_and_free( data, size ); if (!df) { - NSLog(@"EX Failed"); + ALog(@"Open failed for file: %@", [url absoluteString]); return NO; } diff --git a/Plugins/Dumb/DumbDecoder.m b/Plugins/Dumb/DumbDecoder.m index fd18f214d..24b01142f 100755 --- a/Plugins/Dumb/DumbDecoder.m +++ b/Plugins/Dumb/DumbDecoder.m @@ -11,6 +11,8 @@ #import "umx.h" #import "j2b.h" +#import "Logging.h" + @implementation DumbDecoder struct MEMANDFREEFILE @@ -135,7 +137,7 @@ int callbackLoop(void *data) DUMBFILE * df = dumbfile_open_memory_and_free( data, size ); if (!df) { - NSLog(@"EX Failed"); + ALog(@"Open failed for file: %@", [[s url] absoluteString]); return NO; } @@ -160,7 +162,7 @@ int callbackLoop(void *data) duh = dumb_read_any(df, [ext isEqualToString:@"mod"] ? 0 : 1, subsong); if (!duh) { - NSLog(@"Failed to create duh"); + ALog(@"Failed to create duh"); dumbfile_close(df); return NO; } @@ -171,7 +173,7 @@ int callbackLoop(void *data) dsr = duh_start_sigrenderer(duh, 0, 2 /* stereo */, startOrder); if (!dsr) { - NSLog(@"Failed to create dsr"); + ALog(@"Failed to create dsr"); return NO; } diff --git a/Plugins/Dumb/DumbMetadataReader.m b/Plugins/Dumb/DumbMetadataReader.m index f4a7b04b7..0e3fb723e 100644 --- a/Plugins/Dumb/DumbMetadataReader.m +++ b/Plugins/Dumb/DumbMetadataReader.m @@ -11,6 +11,8 @@ #import +#import "Logging.H" + @implementation DumbMetadataReader + (NSArray *)fileTypes @@ -44,7 +46,7 @@ DUMBFILE * df = dumbfile_open_memory_and_free( data, size ); if (!df) { - NSLog(@"EX Failed"); + ALog(@"Open failed for file: %@", [url absoluteString]); return NO; } @@ -56,7 +58,7 @@ if (!duh) { - NSLog(@"Failed to create duh"); + ALog(@"Failed to create duh"); return nil; } diff --git a/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj b/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj index 584f621d9..16601f7ac 100644 --- a/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj +++ b/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 32DBCF630370AF2F00C91783 /* FFMPEG_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFMPEG_Prefix.pch; sourceTree = ""; }; 834225D117FFBD2200DD3E2F /* FFMPEGFileProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFMPEGFileProtocols.h; sourceTree = ""; }; 834225D217FFBD2200DD3E2F /* FFMPEGFileProtocols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFMPEGFileProtocols.m; sourceTree = ""; }; + 8384913818081F6C00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* FFMPEG.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FFMPEG.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B09E942D0D747F410064F138 /* FFMPEGDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FFMPEGDecoder.h; sourceTree = ""; }; @@ -109,6 +110,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384913818081F6C00E7332D /* Logging.h */, 834225D117FFBD2200DD3E2F /* FFMPEGFileProtocols.h */, 834225D217FFBD2200DD3E2F /* FFMPEGFileProtocols.m */, B09E94370D747FAD0064F138 /* Plugin.h */, diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index 94475ad78..f329eaedd 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -12,6 +12,8 @@ #include +#import "Logging.h" + #define ST_BUFF 2048 @implementation FFMPEGDecoder @@ -70,13 +72,13 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) { char errDescr[4096]; av_strerror(errcode, errDescr, 4096); - NSLog(@"ERROR OPENING FILE, errcode = %d, error = %s", errcode, errDescr); + ALog(@"ERROR OPENING FILE, errcode = %d, error = %s", errcode, errDescr); return NO; } if(avformat_find_stream_info(formatCtx, NULL) < 0) { - NSLog(@"CAN'T FIND STREAM INFO!"); + ALog(@"CAN'T FIND STREAM INFO!"); return NO; } @@ -85,25 +87,25 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) codecCtx = formatCtx->streams[i]->codec; if(codecCtx->codec_type == AVMEDIA_TYPE_AUDIO) { - NSLog(@"audio codec found"); + DLog(@"audio codec found"); streamIndex = i; break; } } if ( streamIndex < 0 ) { - NSLog(@"no audio codec found"); + ALog(@"no audio codec found"); return NO; } AVCodec * codec = avcodec_find_decoder(codecCtx->codec_id); if (!codec) { - NSLog(@"codec not found"); + ALog(@"codec not found"); return NO; } if (avcodec_open2(codecCtx, codec, NULL) < 0) { - NSLog(@"could not open codec"); + ALog(@"could not open codec"); return NO; } @@ -184,26 +186,14 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) int bytesToRead = frames * frameSize; int bytesRead = 0; + BOOL endOfStream = NO; + int8_t* targetBuf = (int8_t*) buf; memset(buf, 0, bytesToRead); while (bytesRead < bytesToRead) { - if(readNextPacket) - { - // consume next chunk of encoded data from input stream - av_free_packet(lastReadPacket); - if(av_read_frame(formatCtx, lastReadPacket) < 0) - { - NSLog(@"End of stream"); - break; // end of stream; - } - - readNextPacket = NO; // we probably won't need to consume another chunk - bytesReadFromPacket = 0; // until this one is fully decoded - } - // buffer size needed to hold decoded samples, in bytes int planeSize; int planar = av_sample_fmt_is_planar(codecCtx->sample_fmt); @@ -211,8 +201,27 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) lastDecodedFrame->nb_samples, codecCtx->sample_fmt, 1); + if(readNextPacket && !endOfStream) + { + // consume next chunk of encoded data from input stream + av_free_packet(lastReadPacket); + if(av_read_frame(formatCtx, lastReadPacket) < 0) + { + DLog(@"End of stream"); + endOfStream = YES; + if (dataSize <= bytesConsumedFromDecodedFrame) + break; // end of stream; + } + + readNextPacket = NO; // we probably won't need to consume another chunk + bytesReadFromPacket = 0; // until this one is fully decoded + } + if (dataSize <= bytesConsumedFromDecodedFrame) { + if (endOfStream) + break; + // consumed all decoded samples - decode more avcodec_get_frame_defaults(lastDecodedFrame); bytesConsumedFromDecodedFrame = 0; @@ -221,7 +230,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op) { char errbuf[4096]; av_strerror(len, errbuf, 4096); - NSLog(@"Error decoding: len = %d, gotFrame = %d, strerr = %s", len, gotFrame, errbuf); + ALog(@"Error decoding: len = %d, gotFrame = %d, strerr = %s", len, gotFrame, errbuf); dataSize = 0; readNextPacket = YES; diff --git a/Plugins/Flac/Flac.xcodeproj/project.pbxproj b/Plugins/Flac/Flac.xcodeproj/project.pbxproj index 63d5720d4..2f7c2706c 100644 --- a/Plugins/Flac/Flac.xcodeproj/project.pbxproj +++ b/Plugins/Flac/Flac.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 17C93F040B8FF67A008627D6 /* FlacDecoder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FlacDecoder.m; sourceTree = ""; }; 17F5641A0C3BDC460019975C /* flac.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = flac.xcodeproj; path = ../../Frameworks/FLAC/flac.xcodeproj; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* Flac_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flac_Prefix.pch; sourceTree = ""; }; + 8384912D180816C900E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Flac.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Flac.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -104,6 +105,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384912D180816C900E7332D /* Logging.h */, 177FCFC10B90C9960011C3B5 /* Plugin.h */, 17C93F030B8FF67A008627D6 /* FlacDecoder.h */, 17C93F040B8FF67A008627D6 /* FlacDecoder.m */, diff --git a/Plugins/Flac/FlacDecoder.m b/Plugins/Flac/FlacDecoder.m index 7b23a1bce..7bf8a9874 100644 --- a/Plugins/Flac/FlacDecoder.m +++ b/Plugins/Flac/FlacDecoder.m @@ -8,23 +8,26 @@ #import "FlacDecoder.h" +#import "Logging.h" @implementation FlacDecoder FLAC__StreamDecoderReadStatus ReadCallback(const FLAC__StreamDecoder *decoder, FLAC__byte blockBuffer[], size_t *bytes, void *client_data) { FlacDecoder *flacDecoder = (FlacDecoder *)client_data; - long ret = [[flacDecoder source] read:blockBuffer amount:*bytes]; - *bytes = ret; + long bytesRead = [[flacDecoder source] read:blockBuffer amount:*bytes]; - if(ret < 0) { + if(bytesRead < 0) { + *bytes = 0; return FLAC__STREAM_DECODER_READ_STATUS_ABORT; } - else if(ret == 0) { + else if(bytesRead == 0) { + *bytes = 0; [flacDecoder setEndOfStream:YES]; return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; } else { + *bytes = bytesRead; return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; } } @@ -137,7 +140,7 @@ FLAC__StreamDecoderWriteStatus WriteCallback(const FLAC__StreamDecoder *decoder, } } default: - NSLog(@"Error, unsupported sample size."); + ALog(@"Error, unsupported sample size."); } [flacDecoder setBlockBufferFrames:frame->header.blocksize]; diff --git a/Plugins/GME/GME.xcodeproj/project.pbxproj b/Plugins/GME/GME.xcodeproj/project.pbxproj index 77e42c2c6..2e08a493e 100644 --- a/Plugins/GME/GME.xcodeproj/project.pbxproj +++ b/Plugins/GME/GME.xcodeproj/project.pbxproj @@ -68,6 +68,7 @@ 17DA34B80CC052030003F6B2 /* GameMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameMetadataReader.h; sourceTree = ""; }; 17DA34B90CC052030003F6B2 /* GameMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameMetadataReader.m; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* GME_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GME_Prefix.pch; sourceTree = ""; }; + 8384912E1808175400E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* GME.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GME.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -119,6 +120,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384912E1808175400E7332D /* Logging.h */, 17C8F3470CBED3C7008D969D /* Plugin.h */, 17C8F33B0CBED3BE008D969D /* GameContainer.h */, 17C8F33C0CBED3BE008D969D /* GameContainer.m */, diff --git a/Plugins/GME/GameContainer.m b/Plugins/GME/GameContainer.m index 3d6e7dc32..9a22498f8 100755 --- a/Plugins/GME/GameContainer.m +++ b/Plugins/GME/GameContainer.m @@ -11,6 +11,8 @@ #import "GameContainer.h" #import "GameDecoder.h" +#import "Logging.h" + @implementation GameContainer + (NSArray *)fileTypes @@ -48,7 +50,7 @@ free(data); if (NULL != error) { - NSLog(@"GME: Error loading file: %@ %s", [url path], error); + ALog(@"GME: Error loading file: %@ %s", [url path], error); return [NSArray arrayWithObject:url]; } int track_count = gme_track_count(emu); diff --git a/Plugins/GME/GameDecoder.m b/Plugins/GME/GameDecoder.m index e407312eb..7e343b09b 100755 --- a/Plugins/GME/GameDecoder.m +++ b/Plugins/GME/GameDecoder.m @@ -8,17 +8,19 @@ #import "GameDecoder.h" +#import "Logging.h" + @implementation GameDecoder gme_err_t readCallback( void* data, void* out, long count ) { id source = (id)data; - NSLog(@"Amount: %li", count); + DLog(@"Amount: %li", count); int n = [source read:out amount:count]; - NSLog(@"Read: %i", n); + DLog(@"Read: %i", n); if (n <= 0) { - NSLog(@"ERROR!"); + DLog(@"ERROR!"); return (gme_err_t)1; //Return non-zero for error } @@ -41,14 +43,14 @@ gme_err_t readCallback( void* data, void* out, long count ) gme_type_t type = gme_identify_extension([ext UTF8String]); if (!type) { - NSLog(@"No type!"); + ALog(@"GME: No type!"); return NO; } emu = gme_new_emu(type, 44100); if (!emu) { - NSLog(@"No new emu!"); + ALog(@"GME: No new emu!"); return NO; } @@ -56,12 +58,12 @@ gme_err_t readCallback( void* data, void* out, long count ) long size = [source tell]; [source seek:0 whence:SEEK_SET]; - NSLog(@"Size: %li", size); + DLog(@"Size: %li", size); error = gme_load_custom(emu, readCallback, size, s); if (error) { - NSLog(@"ERROR Loding custom!"); + ALog(@"GME: ERROR Loding custom!"); return NO; } @@ -71,32 +73,33 @@ gme_err_t readCallback( void* data, void* out, long count ) error = gme_track_info( emu, &info, track_num ); if (error) { - NSLog(@"Unable to get track info"); + ALog(@"Unable to get track info"); + return NO; } //As recommended if (info->length > 0) { - NSLog(@"Using length: %i", info->length); + DLog(@"Using length: %i", info->length); length = info->length; } else if (info->loop_length > 0) { - NSLog(@"Using loop length: %i", info->loop_length); + DLog(@"Using loop length: %i", info->loop_length); length = info->intro_length + 2*info->loop_length; } else { length = 150000; - NSLog(@"Setting default: %li", length); + DLog(@"Setting default: %li", length); } gme_free_info( info ); - NSLog(@"Length: %li", length); + DLog(@"Length: %li", length); - NSLog(@"Track num: %i", track_num); + DLog(@"Track num: %i", track_num); error = gme_start_track(emu, track_num); if (error) { - NSLog(@"Error starting track"); + ALog(@"GME: Error starting track"); return NO; } diff --git a/Plugins/GME/GameMetadataReader.m b/Plugins/GME/GameMetadataReader.m index 8320dfbe0..5bf541135 100644 --- a/Plugins/GME/GameMetadataReader.m +++ b/Plugins/GME/GameMetadataReader.m @@ -12,6 +12,8 @@ #import +#import "Logging.h" + @implementation GameMetadataReader + (NSArray *)fileTypes @@ -40,7 +42,7 @@ gme_type_t type = gme_identify_extension([ext UTF8String]); if (!type) { - NSLog(@"No type!"); + ALog(@"GME: No type!"); return NO; } @@ -48,7 +50,7 @@ emu = gme_new_emu(type, gme_info_only); if (!emu) { - NSLog(@"No new emu!"); + ALog(@"GME: No new emu!"); return NO; } @@ -60,7 +62,7 @@ error = gme_load_custom(emu, readCallback, size, source); if (error) { - NSLog(@"ERROR Loding file!"); + ALog(@"GME: ERROR Loding file!"); return NO; } @@ -74,7 +76,7 @@ error = gme_track_info( emu, &info, track_num ); if (error) { - NSLog(@"Unable to get track info"); + ALog(@"GME: Unable to get track info"); } gme_delete(emu); diff --git a/Plugins/HTTPSource/HTTPSource.m b/Plugins/HTTPSource/HTTPSource.m index 0d4663896..175362880 100644 --- a/Plugins/HTTPSource/HTTPSource.m +++ b/Plugins/HTTPSource/HTTPSource.m @@ -9,6 +9,8 @@ #import "HTTPSource.h" #import "HTTPConnection.h" +#import "Logging.h" + @implementation HTTPSource - (BOOL)open:(NSURL *)url @@ -33,7 +35,7 @@ - (NSString *)mimeType { - NSLog(@"Returning mimetype! %@", _mimeType); + DLog(@"Returning mimetype! %@", _mimeType); return _mimeType; } diff --git a/Plugins/HTTPSource/HTTPSource.xcodeproj/project.pbxproj b/Plugins/HTTPSource/HTTPSource.xcodeproj/project.pbxproj index 617e5ffb5..b27720323 100644 --- a/Plugins/HTTPSource/HTTPSource.xcodeproj/project.pbxproj +++ b/Plugins/HTTPSource/HTTPSource.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 17ADB60C0B97A74800257CA2 /* HTTPSource.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTTPSource.h; sourceTree = ""; }; 17ADB6340B97A8B400257CA2 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* HTTPSource_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPSource_Prefix.pch; sourceTree = ""; }; + 8384912F1808180000E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* HTTPSource.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HTTPSource.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -87,6 +88,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384912F1808180000E7332D /* Logging.h */, 17ADB6340B97A8B400257CA2 /* Plugin.h */, 17ADB60C0B97A74800257CA2 /* HTTPSource.h */, 171609390F627F02008FA424 /* HTTPSource.m */, diff --git a/Plugins/HTTPSource/Utils/HTTPConnection.m b/Plugins/HTTPSource/Utils/HTTPConnection.m index bd372e807..9798a5299 100644 --- a/Plugins/HTTPSource/Utils/HTTPConnection.m +++ b/Plugins/HTTPSource/Utils/HTTPConnection.m @@ -10,6 +10,7 @@ #include +#import "Logging.h" @implementation HTTPConnection @@ -89,7 +90,7 @@ // We are using ASCII encoding here because some Icecast servers will insert a random 0xaa or two into the headers // Or I'm an idiot who doesn't know how to count (fixed now), but I don't remember what site I was seeing this on, so I can't really check. NSString *line = [[NSString alloc] initWithBytes:_buffer length:lineLength encoding:NSASCIIStringEncoding]; - NSLog(@"Received line: \"%@\"", line); + DLog(@"Received line: \"%@\"", line); memmove(_buffer, _buffer + lineLength + 2, _bufferSize - lineLength); // + 2 to skip the newline! @@ -132,7 +133,7 @@ NSString *line = [self _receiveLine]; if (nil == line) { // Error receiving data. Let's get out of here! - NSLog(@"Headers ended prematurely"); + DLog(@"Headers ended prematurely"); break; } @@ -151,7 +152,7 @@ [scanner release]; if (NO == success) { - NSLog(@"Could not scan header: %@", line); + DLog(@"Could not scan header: %@", line); continue; } @@ -168,7 +169,7 @@ return [self connect]; } - NSLog(@"Returned status: %li", (long)statusCode); + DLog(@"Returned status: %li", (long)statusCode); return NO; } @@ -212,7 +213,7 @@ [requestString release]; return NO; } - NSLog(@"Sent:\n%@\n", requestString); + DLog(@"Sent:\n%@\n", requestString); [requestString release]; return YES; diff --git a/Plugins/HTTPSource/Utils/Socket.m b/Plugins/HTTPSource/Utils/Socket.m index dabc629a4..5e9ede47a 100644 --- a/Plugins/HTTPSource/Utils/Socket.m +++ b/Plugins/HTTPSource/Utils/Socket.m @@ -9,6 +9,8 @@ #import "Socket.h" #import +#import "Logging.h" + @implementation Socket + (id)socketWithHost:(NSString *)host port:(int)port @@ -34,14 +36,14 @@ he = gethostbyname([host UTF8String]); if (!he) { - NSLog(@"Socket error."); + ALog(@"Socket error: %s\n", strerror(errno)); close(_socket); return nil; } memcpy(&sin.sin_addr, he->h_addr, 4); if (connect(_socket, (struct sockaddr *)&sin, sizeof(sin)) < 0) { - NSLog(@"Error: %s\n", strerror(errno)); + ALog(@"Error: %s\n", strerror(errno)); close(_socket); return nil; } diff --git a/Plugins/M3u/M3u.xcodeproj/project.pbxproj b/Plugins/M3u/M3u.xcodeproj/project.pbxproj index 78de0284f..4f805287e 100644 --- a/Plugins/M3u/M3u.xcodeproj/project.pbxproj +++ b/Plugins/M3u/M3u.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* M3u_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = M3u_Prefix.pch; sourceTree = ""; }; + 83849130180818B100E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* M3u.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = M3u.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8E8D401B0CBAFEF200135C1B /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; }; @@ -71,6 +72,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83849130180818B100E7332D /* Logging.h */, 8E8D401B0CBAFEF200135C1B /* Plugin.h */, 8E8D40270CBAFF4300135C1B /* M3uContainer.h */, 8E8D40280CBAFF4300135C1B /* M3uContainer.m */, diff --git a/Plugins/M3u/M3uContainer.m b/Plugins/M3u/M3uContainer.m index c36dc8467..dc2eeafa1 100644 --- a/Plugins/M3u/M3uContainer.m +++ b/Plugins/M3u/M3uContainer.m @@ -8,6 +8,7 @@ #import "M3uContainer.h" +#import "Logging.h" @implementation M3uContainer @@ -46,7 +47,7 @@ break; } } - NSLog(@"Fragment: %@", fragment); + DLog(@"Fragment: %@", fragment); if (![unixPath hasPrefix:@"/"]) { //Only relative paths would have windows backslashes. @@ -74,22 +75,22 @@ NSError *error = nil; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error]; if (error) { - NSLog(@"Trying UTF8"); + DLog(@"Trying UTF8"); error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; } if (error) { - NSLog(@"Trying windows CP1251"); + DLog(@"Trying windows CP1251"); error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error]; } if (error) { - NSLog(@"Trying latin1"); + DLog(@"Trying latin1"); error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error]; } if (error || !contents) { - NSLog(@"Could not open file...%@ %@ %@", filename, contents, error); + ALog(@"Could not open file...%@ %@ %@", filename, contents, error); return nil; } diff --git a/Plugins/Musepack/Musepack.xcodeproj/project.pbxproj b/Plugins/Musepack/Musepack.xcodeproj/project.pbxproj index 76151f050..54c9c96db 100644 --- a/Plugins/Musepack/Musepack.xcodeproj/project.pbxproj +++ b/Plugins/Musepack/Musepack.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 1703330A0B8FB64500327265 /* MusepackDecoder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MusepackDecoder.m; sourceTree = ""; }; 17F562570C3BD97B0019975C /* MPCDec.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MPCDec.xcodeproj; path = ../../Frameworks/MPCDec/MPCDec.xcodeproj; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* Musepack_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Musepack_Prefix.pch; sourceTree = ""; }; + 838491311808190400E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Musepack.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Musepack.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8E2B8B4A0B9B48D000F2D9E8 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; }; @@ -104,6 +105,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 838491311808190400E7332D /* Logging.h */, 8E2B8B4A0B9B48D000F2D9E8 /* Plugin.h */, 170333090B8FB64500327265 /* MusepackDecoder.h */, 1703330A0B8FB64500327265 /* MusepackDecoder.m */, diff --git a/Plugins/Musepack/MusepackDecoder.m b/Plugins/Musepack/MusepackDecoder.m index 3d845b02e..9493f6bb1 100644 --- a/Plugins/Musepack/MusepackDecoder.m +++ b/Plugins/Musepack/MusepackDecoder.m @@ -8,6 +8,8 @@ #import "MusepackDecoder.h" +#import "Logging.h" + @implementation MusepackDecoder mpc_int32_t ReadProc(void *data, void *ptr, mpc_int32_t size) @@ -71,7 +73,7 @@ mpc_bool_t CanSeekProc(void *data) mpc_streaminfo_init(&info); if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { - NSLog(@"Not a valid musepack file."); + DLog(@"Not a valid musepack file."); return NO; } @@ -79,7 +81,7 @@ mpc_bool_t CanSeekProc(void *data) mpc_decoder_setup(&decoder, &reader); if (!mpc_decoder_initialize(&decoder, &info)) { - NSLog(@"Error initializing decoder."); + DLog(@"Error initializing decoder."); return NO; } @@ -138,7 +140,7 @@ mpc_bool_t CanSeekProc(void *data) if (status == (unsigned)( -1)) { //decode error - NSLog(@"Decode error"); + DLog(@"Decode error"); return 0; } else if (status == 0) //EOF diff --git a/Plugins/Opus/Opus.xcodeproj/project.pbxproj b/Plugins/Opus/Opus.xcodeproj/project.pbxproj index 2fc3caec2..27c303214 100644 --- a/Plugins/Opus/Opus.xcodeproj/project.pbxproj +++ b/Plugins/Opus/Opus.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ 8375B36A17FFF1CB0092A79F /* OpusDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpusDecoder.h; sourceTree = ""; }; 8375B36B17FFF1CB0092A79F /* OpusDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpusDecoder.m; sourceTree = ""; }; 8375B36D17FFF1FE0092A79F /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../../Audio/Plugin.h; sourceTree = ""; }; + 8384913718081F2700E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -112,6 +113,7 @@ 8375B04517FFEA400092A79F /* Opus */ = { isa = PBXGroup; children = ( + 8384913718081F2700E7332D /* Logging.h */, 8375B36D17FFF1FE0092A79F /* Plugin.h */, 8375B36A17FFF1CB0092A79F /* OpusDecoder.h */, 8375B36B17FFF1CB0092A79F /* OpusDecoder.m */, diff --git a/Plugins/Opus/Opus/OpusDecoder.m b/Plugins/Opus/Opus/OpusDecoder.m index 156c9e02d..b0511f476 100644 --- a/Plugins/Opus/Opus/OpusDecoder.m +++ b/Plugins/Opus/Opus/OpusDecoder.m @@ -10,6 +10,7 @@ #import "OpusDecoder.h" +#import "Logging.h" @implementation OpusFile @@ -17,7 +18,7 @@ int sourceRead(void *_stream, unsigned char *_ptr, int _nbytes) { id source = (id)_stream; - return [source read:_ptr amount:_nbytes]; + return (int) [source read:_ptr amount:_nbytes]; } int sourceSeek(void *_stream, opus_int64 _offset, int _whence) @@ -67,7 +68,7 @@ opus_int64 sourceTell(void *_stream) if (!opusRef) { - NSLog(@"FAILED TO OPEN VORBIS FILE"); + DLog(@"FAILED TO OPEN OPUS FILE"); return NO; } diff --git a/Plugins/Pls/Pls.xcodeproj/project.pbxproj b/Plugins/Pls/Pls.xcodeproj/project.pbxproj index 65c03d4f2..825696c16 100644 --- a/Plugins/Pls/Pls.xcodeproj/project.pbxproj +++ b/Plugins/Pls/Pls.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* Pls_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pls_Prefix.pch; sourceTree = ""; }; + 838491321808193F00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Pls.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Pls.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8E8D419F0CBB0CA700135C1B /* PlsContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlsContainer.h; sourceTree = ""; }; @@ -71,6 +72,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 838491321808193F00E7332D /* Logging.h */, 8E8D41A50CBB0CBE00135C1B /* Plugin.h */, 8E8D419F0CBB0CA700135C1B /* PlsContainer.h */, 8E8D41A00CBB0CA700135C1B /* PlsContainer.m */, diff --git a/Plugins/Pls/PlsContainer.m b/Plugins/Pls/PlsContainer.m index 4a2fed2b6..051600c79 100644 --- a/Plugins/Pls/PlsContainer.m +++ b/Plugins/Pls/PlsContainer.m @@ -8,6 +8,7 @@ #import "PlsContainer.h" +#import "Logging.h" @implementation PlsContainer @@ -46,7 +47,7 @@ break; } } - NSLog(@"Fragment: %@", fragment); + DLog(@"Fragment: %@", fragment); if (![unixPath hasPrefix:@"/"]) { //Only relative paths would have windows backslashes. @@ -76,27 +77,25 @@ NSError *error; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error]; if (error) { - NSLog(@"Trying UTF8"); + DLog(@"Trying UTF8"); error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; } if (error) { - NSLog(@"Trying windows CP1251"); + DLog(@"Trying windows CP1251"); error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error]; } if (error) { - NSLog(@"Trying latin1"); + DLog(@"Trying latin1"); error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error]; } if (error || !contents) { - NSLog(@"Could not open file...%@ %@ %@", filename, contents, error); + ALog(@"Could not open file...%@ %@ %@", filename, contents, error); return nil; } - NSString *entry; - NSEnumerator *e = [[contents componentsSeparatedByString:@"\n"] objectEnumerator]; NSMutableArray *entries = [NSMutableArray array]; for (NSString *entry in [contents componentsSeparatedByString:@"\n"]) diff --git a/Plugins/TagLib/TagLib.xcodeproj/project.pbxproj b/Plugins/TagLib/TagLib.xcodeproj/project.pbxproj index ae64c35bf..5d610e6dd 100644 --- a/Plugins/TagLib/TagLib.xcodeproj/project.pbxproj +++ b/Plugins/TagLib/TagLib.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 17C93FC30B90056C008627D6 /* TagLibMetadataReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 17C93FC20B90056C008627D6 /* TagLibMetadataReader.m */; }; 17F563B40C3BDBB30019975C /* TagLib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17F563A60C3BDB8F0019975C /* TagLib.framework */; }; 17F563B60C3BDBB50019975C /* TagLib.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17F563A60C3BDB8F0019975C /* TagLib.framework */; }; + 8384913A18081FFC00E7332D /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 8384913918081FFC00E7332D /* Logging.h */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; /* End PBXBuildFile section */ @@ -57,6 +58,7 @@ 17C93FC20B90056C008627D6 /* TagLibMetadataReader.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = TagLibMetadataReader.m; sourceTree = ""; }; 17F563A00C3BDB8F0019975C /* TagLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = TagLib.xcodeproj; path = ../../Frameworks/TagLib/TagLib.xcodeproj; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* TagLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagLib_Prefix.pch; sourceTree = ""; }; + 8384913918081FFC00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* TagLib.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TagLib.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -107,6 +109,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384913918081FFC00E7332D /* Logging.h */, 07CACE890ED1AD1000C0F1E8 /* TagLibMetadataWriter.h */, 07CACE8A0ED1AD1000C0F1E8 /* TagLibMetadataWriter.m */, 177FCFA40B90C9600011C3B5 /* Plugin.h */, @@ -166,6 +169,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 8384913A18081FFC00E7332D /* Logging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Plugins/TagLib/TagLibMetadataWriter.m b/Plugins/TagLib/TagLibMetadataWriter.m index 6c51e6916..40c6efbf9 100644 --- a/Plugins/TagLib/TagLibMetadataWriter.m +++ b/Plugins/TagLib/TagLibMetadataWriter.m @@ -11,6 +11,8 @@ #import #import +#import "Logging.h" + @implementation TagLibMetadataWriter + (int)putMetadataInURL:(NSURL *)url tagData:(NSDictionary *)tagData @@ -46,7 +48,7 @@ for (id key in dictionary) { - NSLog(@"key: %@, value: %@", key, [dictionary objectForKey:key]); + DLog(@"key: %@, value: %@", key, [dictionary objectForKey:key]); } pArtist = tag->artist(); diff --git a/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj b/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj index ce8b93468..51f117ef1 100644 --- a/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj +++ b/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = VorbisDecoder.m; sourceTree = ""; }; 17F562EF0C3BDAAC0019975C /* Vorbis.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Vorbis.xcodeproj; path = ../../Frameworks/Vorbis/Vorbis.xcodeproj; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* Vorbis_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vorbis_Prefix.pch; sourceTree = ""; }; + 8384913418081A3900E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Vorbis.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Vorbis.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -104,6 +105,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384913418081A3900E7332D /* Logging.h */, 177FCF9D0B90C9530011C3B5 /* Plugin.h */, 17C93D330B8FDA66008627D6 /* VorbisDecoder.h */, 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */, diff --git a/Plugins/Vorbis/VorbisDecoder.m b/Plugins/Vorbis/VorbisDecoder.m index fceb7883f..fe731889f 100644 --- a/Plugins/Vorbis/VorbisDecoder.m +++ b/Plugins/Vorbis/VorbisDecoder.m @@ -8,6 +8,7 @@ #import "VorbisDecoder.h" +#import "Logging.h" @implementation VorbisDecoder @@ -52,7 +53,7 @@ long sourceTell(void *datasource) if (ov_open_callbacks(source, &vorbisRef, NULL, 0, callbacks) != 0) { - NSLog(@"FAILED TO OPEN VORBIS FILE"); + DLog(@"FAILED TO OPEN VORBIS FILE"); return NO; } diff --git a/Plugins/WavPack/WavPack.xcodeproj/project.pbxproj b/Plugins/WavPack/WavPack.xcodeproj/project.pbxproj index 40031a72a..9bb9eb081 100644 --- a/Plugins/WavPack/WavPack.xcodeproj/project.pbxproj +++ b/Plugins/WavPack/WavPack.xcodeproj/project.pbxproj @@ -52,6 +52,7 @@ 177FCF940B90C9450011C3B5 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; }; 17F562C20C3BDA5A0019975C /* WavPack.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WavPack.xcodeproj; path = ../../Frameworks/WavPack/WavPack.xcodeproj; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* WavPack_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WavPack_Prefix.pch; sourceTree = ""; }; + 83849133180819EB00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* WavPack.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WavPack.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; @@ -102,6 +103,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83849133180819EB00E7332D /* Logging.h */, 177FCF940B90C9450011C3B5 /* Plugin.h */, 1745C4D50B90C42500A6768C /* WavPackDecoder.h */, 1745C4D60B90C42500A6768C /* WavPackDecoder.m */, diff --git a/Plugins/WavPack/WavPackDecoder.m b/Plugins/WavPack/WavPackDecoder.m index 3575f547e..4a2a77cad 100644 --- a/Plugins/WavPack/WavPackDecoder.m +++ b/Plugins/WavPack/WavPackDecoder.m @@ -8,6 +8,7 @@ #import "WavPackDecoder.h" +#import "Logging.h" @implementation WavPackDecoder @@ -104,7 +105,7 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount) //No corrections file (WVC) support at the moment. wpc = WavpackOpenFileInputEx(&reader, self, NULL, error, open_flags, 0); if (!wpc) { - NSLog(@"Unable to open file.."); + DLog(@"Unable to open file.."); return NO; } @@ -207,7 +208,7 @@ int32_t WriteBytesProc(void *ds, void *data, int32_t bcount) } break; default: - NSLog(@"Unsupported sample size.."); + ALog(@"Unsupported sample size: %d", bitsPerSample); } free(inputBuffer); diff --git a/Preferences/General/General.xcodeproj/project.pbxproj b/Preferences/General/General.xcodeproj/project.pbxproj index 42741a09e..4afa10e41 100644 --- a/Preferences/General/General.xcodeproj/project.pbxproj +++ b/Preferences/General/General.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 17E78A7D0D68BE3C005C5A59 /* file_tree.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = file_tree.png; path = Icons/file_tree.png; sourceTree = ""; }; 17E78B690D68C1E3005C5A59 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Preferences.xib; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* General_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = General_Prefix.pch; sourceTree = ""; }; + 8384913618081ECB00E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 83EF495D17FBC96A00642E3C /* VolumeBehaviorArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VolumeBehaviorArrayController.h; sourceTree = ""; }; 83EF495E17FBC96A00642E3C /* VolumeBehaviorArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VolumeBehaviorArrayController.m; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* General.preferencePane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = General.preferencePane; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -127,6 +128,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 8384913618081ECB00E7332D /* Logging.h */, 17D503410ABDB1660022D1E8 /* Custom */, 17D5033F0ABDB1570022D1E8 /* Panes */, 17D1B3F60F6349CE00694C57 /* PreferencePanePlugin.h */, diff --git a/Preferences/General/NDHotKeyEvent.m b/Preferences/General/NDHotKeyEvent.m index 9638e3aa6..8805df1ea 100755 --- a/Preferences/General/NDHotKeyEvent.m +++ b/Preferences/General/NDHotKeyEvent.m @@ -10,6 +10,8 @@ #import +#import "Logging.h" + @interface NDHotKeyEvent (Private) + (NSMapTable *)allHotKeyEvents; - (BOOL)addHotKey; @@ -92,7 +94,7 @@ struct HotKeyMappingEntry } else { - NSLog(@"Could not install Event handler"); + DLog(@"Could not install Event handler"); } } NDHotKeyEventUnlock; @@ -409,7 +411,7 @@ struct HotKeyMappingEntry - (void)dealloc { if( UnregisterEventHotKey( reference ) != noErr ) // in lock from release - NSLog( @"Failed to unregister hot key %@", self ); + DLog( @"Failed to unregister hot key %@", self ); [super dealloc]; } @@ -439,7 +441,7 @@ struct HotKeyMappingEntry if( theResult ) isEnabled.individual = aFlag; else - NSLog(@"%s failed ", aFlag ? "enable" : "disable" ); + DLog(@"%s failed ", aFlag ? "enable" : "disable" ); } else theResult = NO; @@ -838,7 +840,7 @@ void hashKeyReleaseFunction( NSMapTable * aTable, void * aNumber ) if( theResult ) isEnabled.collective = aFlag; else - NSLog(@"%s failed", aFlag ? "enable" : "disable" ); + DLog(@"%s failed", aFlag ? "enable" : "disable" ); } else theResult = NO; diff --git a/Preferences/PreferencesWindow.m b/Preferences/PreferencesWindow.m index 01962a430..df407c12f 100644 --- a/Preferences/PreferencesWindow.m +++ b/Preferences/PreferencesWindow.m @@ -9,6 +9,8 @@ #import "PreferencesWindow.h" #import "PreferencePanePlugin.h" +#import "Logging.h" + @interface PreferencesWindow() - (NSString *)lastPaneDefaultsKey; @@ -150,7 +152,7 @@ NSString *lastPane = [[NSUserDefaults standardUserDefaults] objectForKey:[self lastPaneDefaultsKey]]; if (nil == lastPane) { if (0 >= [preferencePaneOrder count]) { - NSLog(@"Error: Preference panes not found!"); + ALog(@"Error: Preference panes not found!"); } lastPane = [preferencePaneOrder objectAtIndex:0]; diff --git a/Spotlight/SpotlightWindowController.m b/Spotlight/SpotlightWindowController.m index 464578698..d3609ae7a 100644 --- a/Spotlight/SpotlightWindowController.m +++ b/Spotlight/SpotlightWindowController.m @@ -15,6 +15,8 @@ #import "NSNumber+CogSort.h" #import "SpotlightTransformers.h" +#import "Logging.h" + // Minimum length of a search string (searching for very small strings gets ugly) #define MINIMUM_SEARCH_STRING_LENGTH 3 @@ -129,7 +131,7 @@ static NSPredicate * musicOnlyPredicate = nil; // Set scope to contents of pathControl self.query.searchScopes = [NSArray arrayWithObjects:pathControl.URL, nil]; [self.query startQuery]; - NSLog(@"Started query: %@", [self.query.predicate description]); + DLog(@"Started query: %@", [self.query.predicate description]); } } } diff --git a/ThirdParty/AppleRemote/AppleRemote.m b/ThirdParty/AppleRemote/AppleRemote.m index 872380de4..c44e0d798 100644 --- a/ThirdParty/AppleRemote/AppleRemote.m +++ b/ThirdParty/AppleRemote/AppleRemote.m @@ -53,6 +53,8 @@ #import "AppleRemote.h" +#import "Logging.h" + const char* AppleRemoteDeviceName = "AppleIRController"; const int REMOTE_SWITCH_COOKIE=19; const NSTimeInterval DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE=0.35; @@ -447,7 +449,7 @@ static AppleRemote* sharedInstance=nil; /* if (previousRemainingCookieString) { cookieString = [previousRemainingCookieString stringByAppendingString: cookieString]; - NSLog(@"New cookie string is %@", cookieString); + DLog(@"New cookie string is %@", cookieString); [previousRemainingCookieString release], previousRemainingCookieString=nil; }*/ if (cookieString == nil || [cookieString length] == 0) return; @@ -468,11 +470,11 @@ static AppleRemote* sharedInstance=nil; // process the last event of the backlog and assume that the button is not pressed down any longer. // The events in the backlog do not seem to be in order and therefore (in rare cases) the last event might be // a button pressed down event while in reality the user has released it. - // NSLog(@"processing last event of backlog"); + // DLog(@"processing last event of backlog"); [self handleEventWithCookieString: lastSubCookieString sumOfValues:0]; } if ([cookieString length] > 0) { - NSLog(@"Unknown button for cookiestring %@", cookieString); + ALog(@"Unknown button for cookiestring %@", cookieString); } } } @@ -520,7 +522,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, ioReturnValue = IOObjectGetClass(hidDevice, className); if (ioReturnValue != kIOReturnSuccess) { - NSLog(@"Error: Failed to get class name."); + ALog(@"Error: Failed to get class name."); return NULL; } @@ -535,7 +537,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, plugInResult = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID) &hidDeviceInterface); if (plugInResult != S_OK) { - NSLog(@"Error: Couldn't create HID class device interface"); + ALog(@"Error: Couldn't create HID class device interface"); } // Release if (plugInInterface) (*plugInInterface)->Release(plugInInterface); @@ -650,13 +652,13 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, (*queue)->start(queue); return YES; } else { - NSLog(@"Error when setting event callout"); + ALog(@"Error when setting event callout"); } } else { - NSLog(@"Error when creating async event source"); + ALog(@"Error when creating async event source"); } } else { - NSLog(@"Error when opening device"); + ALog(@"Error when opening device"); } } return NO; diff --git a/ThirdParty/GCWindowMenu/GCOneShotEffectTimer.m b/ThirdParty/GCWindowMenu/GCOneShotEffectTimer.m index 122184220..9027f44ee 100644 --- a/ThirdParty/GCWindowMenu/GCOneShotEffectTimer.m +++ b/ThirdParty/GCWindowMenu/GCOneShotEffectTimer.m @@ -14,6 +14,8 @@ #import "GCOneShotEffectTimer.h" +#import "Logging.h" + @interface GCOneShotEffectTimer (Private) - (id) initWithTimeInterval:(NSTimeInterval) t forDelegate:(id) del; @@ -80,7 +82,7 @@ NSTimeInterval elapsed = [NSDate timeIntervalSinceReferenceDate] - _start; float val = elapsed / _total; - //NSLog(@"t = %f", val ); + //DLog(@"t = %f", val ); if ( elapsed > _total ) { diff --git a/ThirdParty/GCWindowMenu/GCWindowMenu.m b/ThirdParty/GCWindowMenu/GCWindowMenu.m index ef17a903a..6e17189f0 100644 --- a/ThirdParty/GCWindowMenu/GCWindowMenu.m +++ b/ThirdParty/GCWindowMenu/GCWindowMenu.m @@ -15,6 +15,8 @@ #import "GCWindowMenu.h" #import "GCOneShotEffectTimer.h" +#import "Logging.h" + @interface GCWindowMenu (Private) + (void) popUpWindowMenu:(GCWindowMenu*) menu withEvent:(NSEvent*) event; @@ -256,7 +258,7 @@ { // tracks the "menu" by keeping control until a mouse up (or down, if menu 'clicked' into being) - NSLog(@"starting tracking; initial event = %@", event); + DLog(@"starting tracking; initial event = %@", event); // [NSEvent startPeriodicEventsAfterDelay:1.0 withPeriod:0.1]; @@ -356,7 +358,7 @@ [self discardEventsMatchingMask:NSAnyEventMask beforeEvent:theEvent]; //[NSEvent stopPeriodicEvents]; - NSLog(@"tracking ended"); + DLog(@"tracking ended"); } diff --git a/ThirdParty/NDHotKeys/NDHotKeyEvent.m b/ThirdParty/NDHotKeys/NDHotKeyEvent.m index 9638e3aa6..8805df1ea 100755 --- a/ThirdParty/NDHotKeys/NDHotKeyEvent.m +++ b/ThirdParty/NDHotKeys/NDHotKeyEvent.m @@ -10,6 +10,8 @@ #import +#import "Logging.h" + @interface NDHotKeyEvent (Private) + (NSMapTable *)allHotKeyEvents; - (BOOL)addHotKey; @@ -92,7 +94,7 @@ struct HotKeyMappingEntry } else { - NSLog(@"Could not install Event handler"); + DLog(@"Could not install Event handler"); } } NDHotKeyEventUnlock; @@ -409,7 +411,7 @@ struct HotKeyMappingEntry - (void)dealloc { if( UnregisterEventHotKey( reference ) != noErr ) // in lock from release - NSLog( @"Failed to unregister hot key %@", self ); + DLog( @"Failed to unregister hot key %@", self ); [super dealloc]; } @@ -439,7 +441,7 @@ struct HotKeyMappingEntry if( theResult ) isEnabled.individual = aFlag; else - NSLog(@"%s failed ", aFlag ? "enable" : "disable" ); + DLog(@"%s failed ", aFlag ? "enable" : "disable" ); } else theResult = NO; @@ -838,7 +840,7 @@ void hashKeyReleaseFunction( NSMapTable * aTable, void * aNumber ) if( theResult ) isEnabled.collective = aFlag; else - NSLog(@"%s failed", aFlag ? "enable" : "disable" ); + DLog(@"%s failed", aFlag ? "enable" : "disable" ); } else theResult = NO; diff --git a/Utils/Logging.h b/Utils/Logging.h new file mode 100644 index 000000000..897c97927 --- /dev/null +++ b/Utils/Logging.h @@ -0,0 +1,16 @@ +// +// Logging.h +// Cog +// +// Shamelessly stolen from stackoverflow by Dmitry Promsky on 3/7/12. +// Copyright 2012 dmitry.promsky@gmail.com. All rights reserved. +// + +#ifdef DEBUG +# define DLog(fmt, ...) NSLog((@"%s (line %d) " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); +#else +# define DLog(...) +#endif + +#define ALog(fmt, ...) NSLog((@"%s (line %d) " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); + diff --git a/Utils/SideViewController.m b/Utils/SideViewController.m index 3ac399938..6ec64799a 100644 --- a/Utils/SideViewController.m +++ b/Utils/SideViewController.m @@ -8,6 +8,8 @@ #import "SideViewController.h" +#import "Logging.h" + @implementation SideViewController - (NSString *)showSideViewDefaultsKey @@ -133,7 +135,7 @@ if (![self sideViewIsHidden]) { [[NSUserDefaults standardUserDefaults] setFloat:[self dividerPosition] forKey:[self sideViewDividerPositionDefaultsKey]]; - NSLog(@"DIVIDER POSITION: %f", [self dividerPosition]); + DLog(@"DIVIDER POSITION: %f", [self dividerPosition]); } } diff --git a/Window/PlaybackButtons.m b/Window/PlaybackButtons.m index 09b6885f1..8174e3e93 100644 --- a/Window/PlaybackButtons.m +++ b/Window/PlaybackButtons.m @@ -11,6 +11,8 @@ #import +#import "Logging.h" + @implementation PlaybackButtons static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackButtonsPlaybackStatusObservationContext"; @@ -62,7 +64,7 @@ static NSString *PlaybackButtonsPlaybackStatusObservationContext = @"PlaybackBut - (BOOL)sendAction:(SEL)theAction to:(id)theTarget { - NSLog(@"Mouse down!"); + DLog(@"Mouse down!"); int clickedSegment = [self selectedSegment]; if (clickedSegment == 0) //Previous diff --git a/Window/RepeatTransformers.m b/Window/RepeatTransformers.m index 14418bdad..51860045b 100644 --- a/Window/RepeatTransformers.m +++ b/Window/RepeatTransformers.m @@ -9,6 +9,8 @@ #import "RepeatTransformers.h" #import "PlaylistController.h" +#import "Logging.h" + @implementation RepeatModeTransformer + (Class)transformedValueClass { return [NSNumber class]; } @@ -27,7 +29,7 @@ // Convert from RepeatMode to BOOL - (id)transformedValue:(id)value { - NSLog(@"Transforming value: %@", value); + DLog(@"Transforming value: %@", value); if (value == nil) return nil; @@ -65,7 +67,7 @@ // Convert from string to RepeatMode - (id)transformedValue:(id)value { - NSLog(@"Transforming value: %@", value); + DLog(@"Transforming value: %@", value); if (value == nil) return nil; diff --git a/Window/ShuffleTransformers.m b/Window/ShuffleTransformers.m index d3a8d64a7..517f66c58 100644 --- a/Window/ShuffleTransformers.m +++ b/Window/ShuffleTransformers.m @@ -7,6 +7,9 @@ // #import "ShuffleTransformers.h" + +#import "Logging.h" + @implementation ShuffleImageTransformer + (Class)transformedValueClass { return [NSImage class]; } @@ -14,7 +17,7 @@ // Convert from string to RepeatMode - (id)transformedValue:(id)value { - NSLog(@"Transforming value: %@", value); + DLog(@"Transforming value: %@", value); if (value == nil) return nil; @@ -54,7 +57,7 @@ // Convert from RepeatMode to BOOL - (id)transformedValue:(id)value { - NSLog(@"Transforming value: %@", value); + DLog(@"Transforming value: %@", value); if (value == nil) return nil;