Source/GGBUtils.m
changeset 20 7c9ecb09a612
parent 12 4e567e11f45f
child 21 2eb229411d73
     1.1 --- a/Source/GGBUtils.m	Mon Jul 07 15:47:42 2008 -0700
     1.2 +++ b/Source/GGBUtils.m	Fri Jul 18 13:26:59 2008 -0700
     1.3 @@ -19,10 +19,7 @@
     1.4      THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     1.5  */
     1.6  #import "GGBUtils.h"
     1.7 -
     1.8 -#if TARGET_OS_IPHONE
     1.9  #import <AudioToolbox/AudioToolbox.h>
    1.10 -#endif
    1.11  
    1.12  
    1.13  #ifndef _MYUTILITIES_COLLECTIONUTILS_
    1.14 @@ -54,7 +51,6 @@
    1.15  }    
    1.16  
    1.17  
    1.18 -#if TARGET_OS_IPHONE
    1.19  static SystemSoundID GetSound( NSString *name )
    1.20  {
    1.21      static NSMutableDictionary *sSoundIDs;
    1.22 @@ -64,19 +60,24 @@
    1.23          NSString *type = name.pathExtension;
    1.24          if( ! type.length )
    1.25              type = @"aiff";
    1.26 -        NSString *path = [[NSBundle mainBundle] pathForResource: name.stringByDeletingPathExtension
    1.27 +        name = name.stringByDeletingPathExtension;
    1.28 +        
    1.29 +        NSString *path = [[NSBundle mainBundle] pathForResource: name
    1.30                                                           ofType: type];
    1.31 +#if ! TARGET_OS_IPHONE
    1.32 +        if( ! path )
    1.33 +            path = [@"/System/Library/Sounds" stringByAppendingPathComponent: [name stringByAppendingPathExtension: type]];
    1.34 +#endif
    1.35          NSURL *url;
    1.36          if( path )
    1.37              url = [NSURL fileURLWithPath: path];
    1.38          else {
    1.39 -            NSLog(@"Couldn't find sound %@",name);
    1.40 +            NSLog(@"WARNING: Couldn't find sound %@",name);
    1.41              return 0;
    1.42          }
    1.43 -        //url = [NSURL fileURLWithPath: [@"/Library/Sounds/" stringByAppendingPathComponent: name]];
    1.44          SystemSoundID soundID;
    1.45          if( AudioServicesCreateSystemSoundID((CFURLRef)url,&soundID) != noErr ) {
    1.46 -            NSLog(@"Couldn't load sound %@",url);
    1.47 +            NSLog(@"WARNING: Couldn't load sound %@",url);
    1.48              return 0;
    1.49          }
    1.50          
    1.51 @@ -87,29 +88,17 @@
    1.52      }
    1.53      return [soundIDObj unsignedIntValue];
    1.54  }
    1.55 -#endif
    1.56  
    1.57  
    1.58  void PreloadSound( NSString* name )
    1.59  {
    1.60 -#if TARGET_OS_IPHONE
    1.61 -    GetSound(name);
    1.62 -#else
    1.63 -    NSSound *sound = [[NSSound soundNamed: @"Pop"] copy];
    1.64 -    sound.volume = 0;
    1.65 -    [sound play];
    1.66 -    [sound release];
    1.67 -#endif
    1.68 +    (void) GetSound(name);
    1.69  }    
    1.70  
    1.71  
    1.72  void PlaySound( NSString* name )
    1.73  {
    1.74 -#if TARGET_OS_IPHONE
    1.75      AudioServicesPlaySystemSound( GetSound(name) );
    1.76 -#else
    1.77 -    [[NSSound soundNamed: name] play];
    1.78 -#endif
    1.79  }
    1.80  
    1.81  void Beep()