From d3d7589833a0964dac6d19412bf22037400ed757 Mon Sep 17 00:00:00 2001 From: demosthenese Date: Fri, 1 Jul 2011 10:47:54 +0000 Subject: [PATCH] Updated Sound Manager to version 1.1.2 --- LICENCE.md | 2 +- RELEASE NOTES.md | 6 ++++++ SoundManager/SoundManager.h | 2 +- SoundManager/SoundManager.m | 22 ++++++++++++++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/LICENCE.md b/LICENCE.md index 4aee7ac..e20ea08 100755 --- a/LICENCE.md +++ b/LICENCE.md @@ -1,6 +1,6 @@ SoundManager -Version 1.1.1, June 29th, 2011 +Version 1.1.2, June 29th, 2011 Copyright (C) 2011 Charcoal Design diff --git a/RELEASE NOTES.md b/RELEASE NOTES.md index 3807a6a..566d57b 100755 --- a/RELEASE NOTES.md +++ b/RELEASE NOTES.md @@ -1,3 +1,9 @@ +Version 1.1.2 + +- Fixed occasional crash due to accessing sound after it is released +- Sound manager will now log a warning to the console when passed a non-existent sound file instead of crashing +- Sound names can now include directory separators. This means that sounds in subfolders of the resource folder can be played using the standard play functions. + Version 1.1.1 - Fixed bugs with music fading diff --git a/SoundManager/SoundManager.h b/SoundManager/SoundManager.h index 86d65ba..1c46f40 100644 --- a/SoundManager/SoundManager.h +++ b/SoundManager/SoundManager.h @@ -1,7 +1,7 @@ // // SoundManager.h // -// Version 1.1.1 +// Version 1.1.2 // // Created by Nick Lockwood on 29/01/2011. // Copyright 2010 Charcoal Design. All rights reserved. diff --git a/SoundManager/SoundManager.m b/SoundManager/SoundManager.m index 6b8d41f..4e06cd7 100644 --- a/SoundManager/SoundManager.m +++ b/SoundManager/SoundManager.m @@ -1,7 +1,7 @@ // // SoundManager.m // -// Version 1.1.1 +// Version 1.1.2 // // Created by Nick Lockwood on 29/01/2011. // Copyright 2010 Charcoal Design. All rights reserved. @@ -88,8 +88,19 @@ - (Sound *)initWithName:(NSString *)_name; { _name = [_name stringByAppendingPathExtension:FILE_EXTENSION]; } - NSString *path = [[NSBundle mainBundle] pathForResource:_name ofType:nil]; - return [self initWithURL:[NSURL fileURLWithPath:path]]; + + NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:_name]; + +#ifdef DEBUG + + if (![[NSFileManager defaultManager] fileExistsAtPath:path]) + { + NSLog(@"Sound file '%@' does not exist", _name); + } + +#endif + + return [self initWithURL:[NSURL fileURLWithPath:path]]; } - (Sound *)initWithURL:(NSURL *)_url; @@ -204,7 +215,9 @@ - (void)stop [(NSSound *)sound stop]; #endif - self.selfReference = nil; + //autorelease so sound is not released immediately + [selfReference autorelease]; + selfReference = nil; } #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED @@ -214,6 +227,7 @@ - (void)sound:(NSSound *)_sound didFinishPlaying:(BOOL)finishedPlaying #endif { [self stop]; + [[NSNotificationCenter defaultCenter] postNotificationName:SoundFinishedPlayingNotification object:self]; }