ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
authorkoda
Sat, 24 Sep 2011 00:54:47 +0200
changeset 6000 dbcebcd3d79f
parent 5998 e8f44e9433f0
child 6002 7f790689205c
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
project_files/HedgewarsMobile/Classes/AboutViewController.m
project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m
project_files/HedgewarsMobile/Classes/AudioManagerController.h
project_files/HedgewarsMobile/Classes/AudioManagerController.m
project_files/HedgewarsMobile/Classes/CommodityFunctions.h
project_files/HedgewarsMobile/Classes/CommodityFunctions.m
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m
project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.h
project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m
project_files/HedgewarsMobile/Classes/MainMenuViewController.m
project_files/HedgewarsMobile/Classes/MapConfigViewController.m
project_files/HedgewarsMobile/Classes/MasterViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/RestoreViewController.m
project_files/HedgewarsMobile/Classes/SavedGamesViewController.m
project_files/HedgewarsMobile/Classes/SplitViewRootController.m
project_files/HedgewarsMobile/Classes/StatsPageViewController.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
project_files/HedgewarsMobile/Hedgewars_Prefix.pch
--- a/project_files/HedgewarsMobile/Classes/AboutViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/AboutViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -50,12 +50,12 @@
 }
 
 -(IBAction) buttonPressed:(id) sender {
-    playSound(@"backSound");
+    [AudioManagerController playBackSound];
     [[self parentViewController] dismissModalViewControllerAnimated:YES];
 }
 
 -(IBAction) segmentedControlChanged:(id) sender {
-    playSound(@"clickSound");
+    [AudioManagerController playClickSound];
     [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
     [self.tableView reloadData];
 }
--- a/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/AmmoMenuViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -297,7 +297,7 @@
 
     if (theButton.currentTitle == nil) {
         HW_setWeapon(theButton.tag);
-        playSound(@"clickSound");
+        [AudioManagerController playClickSound];
         if (IS_DUALHEAD() == NO)
             [self disappear];
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/AudioManagerController.h	Sat Sep 24 00:54:47 2011 +0200
@@ -0,0 +1,39 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * File created on 13/03/2011.
+ */
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface AudioManagerController : NSObject {
+
+}
+
++(void) playBackgroundMusic;
++(void) pauseBackgroundMusic;
++(void) stopBackgroundMusic;
+
++(void) playClickSound;
++(void) playBackSound;
++(void) playSelectSound;
+
++(void) didReceiveMemoryWarning;
+
+@end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/HedgewarsMobile/Classes/AudioManagerController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -0,0 +1,126 @@
+/*
+ * Hedgewars-iOS, a Hedgewars port for iOS devices
+ * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * File created on 13/03/2011.
+ */
+
+
+#import "AudioManagerController.h"
+#import "AVFoundation/AVAudioPlayer.h"
+#import <AudioToolbox/AudioToolbox.h>
+
+
+static AVAudioPlayer *backgroundMusic = nil;
+static SystemSoundID clickSound = -1;
+static SystemSoundID backSound = -1;
+static SystemSoundID selSound = -1;
+
+@implementation AudioManagerController
+
+#pragma mark -
+#pragma mark background music control
++(void) loadBackgroundMusic {
+    NSString *musicString = [[NSBundle mainBundle] pathForResource:@"hwclassic" ofType:@"mp3"];
+    backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicString] error:nil];
+
+    backgroundMusic.delegate = nil;
+    backgroundMusic.volume = 0.4f;
+    backgroundMusic.numberOfLoops = -1;
+    [backgroundMusic prepareToPlay];
+}
+
++(void) playBackgroundMusic {
+    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"music"] boolValue] == NO)
+        return;
+
+    if (backgroundMusic == nil)
+        [AudioManagerController loadBackgroundMusic];
+
+    [backgroundMusic play];
+}
+
++(void) pauseBackgroundMusic {
+    [backgroundMusic pause];
+}
+
++(void) stopBackgroundMusic {
+    [backgroundMusic stop];
+}
+
+#pragma mark -
+#pragma mark sound effects control
++(SystemSoundID) loadSound:(NSString *)snd {
+    // get the filename of the sound file:
+    NSString *path = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] resourcePath],snd];
+
+    // declare a system sound id and get a URL for the sound file
+    SystemSoundID soundID;
+    NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
+
+    // use audio sevices to create and play the sound
+    AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
+    return soundID;
+}
+
++(void) playClickSound {
+    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == NO)
+        return;
+    
+    if (clickSound == -1)
+        clickSound = [AudioManagerController loadSound:@"clickSound.wav"];
+    
+    AudioServicesPlaySystemSound(clickSound);
+}
+
++(void) playBackSound {
+    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == NO)
+        return;
+    
+    if (backSound == -1)
+        backSound = [AudioManagerController loadSound:@"backSound.wav"];
+    
+    AudioServicesPlaySystemSound(backSound);
+}
+
++(void) playSelectSound {
+    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == NO)
+        return;
+    
+    if (selSound == -1)
+        selSound = [AudioManagerController loadSound:@"selSound.wav"];
+    
+    AudioServicesPlaySystemSound(selSound);
+}
+
+#pragma mark -
+#pragma mark memory management
++(void) didReceiveMemoryWarning {
+    [backgroundMusic stop];
+    backgroundMusic = nil;
+    clickSound = -1;
+    backSound = -1;
+}
+
++(void) dealloc {
+    releaseAndNil(backgroundMusic);
+    AudioServicesDisposeSystemSoundID(clickSound), clickSound = -1;
+    AudioServicesDisposeSystemSoundID(backSound), backSound = -1;
+    AudioServicesDisposeSystemSoundID(selSound), selSound = -1;
+    [super dealloc];
+}
+
+@end
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.h	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.h	Sat Sep 24 00:54:47 2011 +0200
@@ -64,7 +64,6 @@
 #define UIVIEW_HW_SDLVIEW       [[[[UIApplication sharedApplication] keyWindow] subviews] objectAtIndex:0]
 
 void print_free_memory (void);
-void playSound (NSString *snd);
 NSInteger randomPort (void);
 
 NSString *getModelType (void);
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.m	Sat Sep 24 00:54:47 2011 +0200
@@ -25,7 +25,6 @@
 #import <mach/mach.h>
 #import <mach/mach_host.h>
 #import <QuartzCore/QuartzCore.h>
-#import <AudioToolbox/AudioToolbox.h>
 #import <CommonCrypto/CommonDigest.h>
 #import <SystemConfiguration/SCNetworkReachability.h>
 #import <netinet/in.h>
@@ -76,21 +75,6 @@
     return modelId;
 }
 
-void playSound (NSString *snd) {
-    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"sound"] boolValue] == YES) {
-        // get the filename of the sound file:
-        NSString *path = [NSString stringWithFormat:@"%@/%@.wav",[[NSBundle mainBundle] resourcePath],snd];
-
-        // declare a system sound id and get a URL for the sound file
-        SystemSoundID soundID;
-        NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
-
-        // use audio sevices to create and play the sound
-        AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
-        AudioServicesPlaySystemSound(soundID);
-    }
-}
-
 NSArray *getAvailableColors (void) {
     // by default colors are ARGB but we do computation over RGB, hence we have to "& 0x00FFFFFF" before processing
     unsigned int colors[] = HW_TEAMCOLOR_ARRAY;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -51,17 +51,17 @@
                 [alert show];
                 [alert release];
             } else {
-                playSound(@"backSound");
+                [AudioManagerController playBackSound];
                 [[self parentViewController] dismissModalViewControllerAnimated:YES];
             }
             break;
         case 1:
-            playSound(@"clickSound");
+            [AudioManagerController playClickSound];
             theButton.enabled = NO;
             [self startGame:theButton];
             break;
         case 2:
-            playSound(@"clickSound");
+            [AudioManagerController playClickSound];
             if (self.helpPage == nil)
                 self.helpPage = [[HelpPageViewController alloc] initWithNibName:@"HelpPageLobbyViewController-iPad" bundle:nil];
             self.helpPage.view.alpha = 0;
@@ -79,7 +79,7 @@
 -(IBAction) segmentPressed:(id) sender {
     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
 
-    playSound(@"selSound");
+    [AudioManagerController playSelectSound];
     switch (theSegment.selectedSegmentIndex) {
         case 0:
             // this init here is just aestetic as this controller was already set up in viewDidLoad
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Sat Sep 24 00:54:47 2011 +0200
@@ -24,6 +24,7 @@
 #import "EngineProtocolNetwork.h"
 #import "OverlayViewController.h"
 #import "StatsPageViewController.h"
+#import "AudioManagerController.h"
 #import "ObjcExports.h"
 
 @implementation GameInterfaceBridge
@@ -154,7 +155,7 @@
     [userDefaults setObject:self.savePath forKey:@"savedGamePath"];
     [userDefaults synchronize];
 
-    [HedgewarsAppDelegate pauseBackgroundMusic];
+    [AudioManagerController pauseBackgroundMusic];
 
     // SYSTEMS ARE GO!!
     [self startGameEngine];
@@ -177,8 +178,7 @@
     // warn our host that it's going to be visible again
     [self.parentController viewWillAppear:YES];
 
-    if ([[userDefaults objectForKey:@"music"] boolValue])
-        [HedgewarsAppDelegate playBackgroundMusic];
+    [AudioManagerController playBackgroundMusic];
 }
 
 // set up variables for a local game
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -22,6 +22,7 @@
 #import "GeneralSettingsViewController.h"
 #import "CommodityFunctions.h"
 
+
 @implementation GeneralSettingsViewController
 
 
@@ -44,7 +45,7 @@
     NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
     [userDefaults synchronize];
     if ([[userDefaults objectForKey:@"music"] boolValue] == NO)
-        [HedgewarsAppDelegate stopBackgroundMusic];
+        [AudioManagerController stopBackgroundMusic];
 
     [super viewWillDisappear:animated];
 }
@@ -64,7 +65,7 @@
             [theOtherSwitch setOn:NO animated:YES];
 
             if (theOtherSwitch.on)
-                [HedgewarsAppDelegate pauseBackgroundMusic];
+                [AudioManagerController pauseBackgroundMusic];
             break;
         case 20:    //musicSwitch
             // if switch above (sound) is off, never turn on
@@ -76,9 +77,9 @@
                 [settings setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"music"];
 
             if (theSwitch.on)
-                [HedgewarsAppDelegate playBackgroundMusic];
+                [AudioManagerController playBackgroundMusic];
             else
-                [HedgewarsAppDelegate pauseBackgroundMusic];
+                [AudioManagerController pauseBackgroundMusic];
 
             break;
         case 30:    //alternateSwitch
--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.h	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.h	Sat Sep 24 00:54:47 2011 +0200
@@ -23,27 +23,20 @@
 #import "SDL_uikitappdelegate.h"
 
 @class MainMenuViewController;
-@class AVAudioPlayer;
 
 @interface HedgewarsAppDelegate : SDLUIKitDelegate {
     MainMenuViewController *mainViewController;
     UIWindow *uiwindow;
     UIWindow *secondWindow;
     BOOL isInGame;
-    AVAudioPlayer *backgroundMusic;
 }
 
 @property (nonatomic,retain) MainMenuViewController *mainViewController;
 @property (nonatomic,retain) UIWindow *uiwindow;
 @property (nonatomic,retain) UIWindow *secondWindow;
 @property (assign) BOOL isInGame;
-@property (nonatomic,retain) AVAudioPlayer *backgroundMusic;
 
 +(HedgewarsAppDelegate *)sharedAppDelegate;
-+(void) playBackgroundMusic;
-+(void) pauseBackgroundMusic;
-+(void) stopBackgroundMusic;
-+(void) loadBackgroundMusic;
 
 @end
 
--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Sat Sep 24 00:54:47 2011 +0200
@@ -24,7 +24,6 @@
 #import "ObjcExports.h"
 #import "CommodityFunctions.h"
 #import "MainMenuViewController.h"
-#import "AVFoundation/AVAudioPlayer.h"
 #include <unistd.h>
 
 
@@ -37,7 +36,7 @@
 @end
 
 @implementation HedgewarsAppDelegate
-@synthesize mainViewController, uiwindow, secondWindow, isInGame, backgroundMusic;
+@synthesize mainViewController, uiwindow, secondWindow, isInGame;
 
 // convenience method
 +(HedgewarsAppDelegate *)sharedAppDelegate {
@@ -45,34 +44,6 @@
 }
 
 #pragma mark -
-#pragma mark Music control
-+(void) playBackgroundMusic {
-    if ([HedgewarsAppDelegate sharedAppDelegate].backgroundMusic == nil)
-        [HedgewarsAppDelegate loadBackgroundMusic];
-    [[HedgewarsAppDelegate sharedAppDelegate].backgroundMusic play];
-}
-
-+(void) pauseBackgroundMusic {
-    [[HedgewarsAppDelegate sharedAppDelegate].backgroundMusic pause];
-}
-
-+(void) stopBackgroundMusic {
-    [[HedgewarsAppDelegate sharedAppDelegate].backgroundMusic stop];
-}
-
-+(void) loadBackgroundMusic {
-    NSString *musicString = [[NSBundle mainBundle] pathForResource:@"hwclassic" ofType:@"mp3"];
-    AVAudioPlayer *background = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicString] error:nil];
-
-    background.delegate = nil;
-    background.volume = 0.4f;
-    background.numberOfLoops = -1;
-    [background prepareToPlay];
-    [HedgewarsAppDelegate sharedAppDelegate].backgroundMusic = background;
-    [background release];
-}
-
-#pragma mark -
 #pragma mark AppDelegate methods
 -(id) init {
     if (self = [super init]){
@@ -80,7 +51,6 @@
         uiwindow = nil;
         secondWindow = nil;
         isInGame = NO;
-        backgroundMusic = nil;
     }
     return self;
 }
@@ -89,7 +59,6 @@
     [mainViewController release];
     [uiwindow release];
     [secondWindow release];
-    [backgroundMusic release];
     [super dealloc];
 }
 
@@ -125,8 +94,7 @@
 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
     // don't stop music when it is playing
     if (self.isInGame) {
-        [self.backgroundMusic stop];
-        self.backgroundMusic = nil;
+        [AudioManagerController didReceiveMemoryWarning];
         MSG_MEMCLEAN();
     }
     print_free_memory();
@@ -136,7 +104,7 @@
 // true multitasking with sdl works only on 4.2 and above; we close the game to avoid a black screen at return
 -(void) applicationWillResignActive:(UIApplication *)application {
     if (self.isInGame && [[[UIDevice currentDevice] systemVersion] floatValue] < 4.2f)
-            HW_terminate(NO);
+         HW_terminate(NO);
 
     [super applicationWillResignActive:application];
 }
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -30,6 +30,7 @@
 #import "Appirater.h"
 #import "ServerSetup.h"
 
+
 @implementation MainMenuViewController
 @synthesize gameConfigViewController, settingsViewController, aboutViewController, savedGamesViewController, restoreViewController;
 
@@ -106,7 +107,7 @@
     NSString *trackingVersion = [userDefaults stringForKey:@"HedgeVersion"];
 
     if ([[userDefaults objectForKey:@"music"] boolValue])
-        [HedgewarsAppDelegate playBackgroundMusic];
+        [AudioManagerController playBackgroundMusic];
 
     if (trackingVersion == nil || [trackingVersion isEqualToString:version] == NO) {
         // remove any reminder of previous games as saves are going to be wiped out
@@ -156,7 +157,7 @@
     NSString *xib = nil;
     NSString *debugStr = nil;
 
-    playSound(@"clickSound");
+    [AudioManagerController playClickSound];
     switch (button.tag) {
         case 0:
             if (nil == self.gameConfigViewController) {
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -40,7 +40,7 @@
 }
 
 -(IBAction) mapButtonPressed {
-    playSound(@"clickSound");
+    [AudioManagerController playClickSound];
     [self updatePreview];
 }
 
@@ -307,7 +307,7 @@
         [self updatePreview];
         oldValue = num;
     }
-    playSound(@"clickSound");
+    [AudioManagerController playClickSound];
 }
 
 // perform actions based on the activated section, then call updatePreview to visually update the selection
@@ -316,7 +316,7 @@
     NSString *mapgen, *staticmap, *mission;
     NSInteger newPage = self.segmentedControl.selectedSegmentIndex;
 
-    playSound(@"selSound");
+    [AudioManagerController playSelectSound];
     switch (newPage) {
         case 0: // Random
             mapgen = @"e$mapgen 0";
--- a/project_files/HedgewarsMobile/Classes/MasterViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MasterViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -166,7 +166,7 @@
             nextController.navigationItem.hidesBackButton = NO;
             [self.navigationController pushViewController:nextController animated:YES];
         } else {
-            playSound(@"clickSound");
+            [AudioManagerController playClickSound];
             nextController.navigationItem.hidesBackButton = YES;
             [targetController.navigationController pushViewController:nextController animated:NO];
         }
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -278,7 +278,7 @@
             HW_backjump();
             break;
         case 10:
-            playSound(@"clickSound");
+            [AudioManagerController playClickSound];
             clearView();
             HW_pause();
             if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
@@ -289,7 +289,7 @@
             [self showPopover];
             break;
         case 11:
-            playSound(@"clickSound");
+            [AudioManagerController playClickSound];
             clearView();
             
             if (IS_DUALHEAD() || [[[NSUserDefaults standardUserDefaults] objectForKey:@"classic_menu"] boolValue] == NO) {
--- a/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/RestoreViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -36,7 +36,7 @@
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
     if (theButton.tag != 0) {
-        playSound(@"clickSound");
+        [AudioManagerController playClickSound];
         if (self.interfaceBridge == nil) {
             GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self.parentViewController];
             self.interfaceBridge = bridge;
@@ -45,7 +45,7 @@
         [self.parentViewController dismissModalViewControllerAnimated:NO];
         [self.interfaceBridge startSaveGame:[defaults objectForKey:@"savedGamePath"]];
     } else {
-        playSound(@"backSound");
+        [AudioManagerController playBackSound];
         [defaults setObject:@"" forKey:@"savedGamePath"];
         [defaults synchronize];
         [self.parentViewController dismissModalViewControllerAnimated:YES];
--- a/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SavedGamesViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -69,7 +69,7 @@
     UIButton *button = (UIButton *)sender;
 
     if (button.tag == 0) {
-        playSound(@"backSound");
+        [AudioManagerController playBackSound];
         [self.tableView setEditing:NO animated:YES];
         [[self parentViewController] dismissModalViewControllerAnimated:YES];
     } else {
--- a/project_files/HedgewarsMobile/Classes/SplitViewRootController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SplitViewRootController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -77,7 +77,7 @@
 }
 
 -(void) dismissModalViewControllerAnimated:(BOOL)animated {
-    playSound(@"backSound");
+    [AudioManagerController playBackSound];
     [self.parentViewController dismissModalViewControllerAnimated:YES];
 }
 
--- a/project_files/HedgewarsMobile/Classes/StatsPageViewController.m	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/StatsPageViewController.m	Sat Sep 24 00:54:47 2011 +0200
@@ -146,7 +146,7 @@
 #pragma mark Table view delegate
 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     if ([indexPath section] == 3) {
-        playSound(@"backSound");
+        [AudioManagerController playBackSound];
         [self dismissModalViewControllerAnimated:YES];
     }
 }
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sat Sep 24 00:54:47 2011 +0200
@@ -214,6 +214,7 @@
 		61B7A61812FA13B00051E14E /* libSDL_net.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A56812FA12D00051E14E /* libSDL_net.a */; };
 		61B7A61912FA13B00051E14E /* libSDL_ttf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B7A59012FA13330051E14E /* libSDL_ttf.a */; };
 		61C079E411F35A300072BF46 /* EditableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 61C079E311F35A300072BF46 /* EditableCellView.m */; };
+		61C28D3F142D380400DA16C2 /* AudioManagerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61C28D3E142D380400DA16C2 /* AudioManagerController.m */; };
 		61CADE331402EE290030C3EB /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61CADE321402EE290030C3EB /* ImageIO.framework */; };
 		61D205A1127CDD1100ABD83E /* ObjcExports.m in Sources */ = {isa = PBXBuildFile; fileRef = 61D205A0127CDD1100ABD83E /* ObjcExports.m */; };
 		61D3D2A51290E03A003CE7C3 /* irc.png in Resources */ = {isa = PBXBuildFile; fileRef = 61D3D2A41290E03A003CE7C3 /* irc.png */; };
@@ -572,6 +573,8 @@
 		61B7A33712CC21080086B604 /* StatsPageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StatsPageViewController.m; sourceTree = "<group>"; };
 		61C079E211F35A300072BF46 /* EditableCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EditableCellView.h; path = Classes/EditableCellView.h; sourceTree = "<group>"; };
 		61C079E311F35A300072BF46 /* EditableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EditableCellView.m; path = Classes/EditableCellView.m; sourceTree = "<group>"; };
+		61C28D3D142D380400DA16C2 /* AudioManagerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioManagerController.h; sourceTree = "<group>"; };
+		61C28D3E142D380400DA16C2 /* AudioManagerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioManagerController.m; sourceTree = "<group>"; };
 		61CADE321402EE290030C3EB /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
 		61D2059F127CDD1100ABD83E /* ObjcExports.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjcExports.h; path = Classes/ObjcExports.h; sourceTree = "<group>"; };
 		61D205A0127CDD1100ABD83E /* ObjcExports.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ObjcExports.m; path = Classes/ObjcExports.m; sourceTree = "<group>"; };
@@ -666,6 +669,8 @@
 				616591E711CA9BA200D6E256 /* EngineProtocolNetwork.m */,
 				61E2E12C12BAAEE30051B659 /* ServerSetup.h */,
 				61E2E12D12BAAEE30051B659 /* ServerSetup.m */,
+				61C28D3D142D380400DA16C2 /* AudioManagerController.h */,
+				61C28D3E142D380400DA16C2 /* AudioManagerController.m */,
 			);
 			path = Classes;
 			sourceTree = "<group>";
@@ -1589,6 +1594,7 @@
 				61EDB5B0135B3F97009B29A6 /* GameInterfaceBridge.m in Sources */,
 				61A976B3136F668500DD9878 /* uCursor.pas in Sources */,
 				6167A6761391514600AA6D07 /* RestoreViewController.m in Sources */,
+				61C28D3F142D380400DA16C2 /* AudioManagerController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/project_files/HedgewarsMobile/Hedgewars_Prefix.pch	Fri Sep 23 22:42:30 2011 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars_Prefix.pch	Sat Sep 24 00:54:47 2011 +0200
@@ -28,10 +28,7 @@
 #import "UIImageExtra.h"
 #import "CommodityFunctions.h"
 #import "HedgewarsAppDelegate.h"
-#import "SDL.h"
-#import "SDL_video.h"
-#import "SDL_net.h"
-#import "SDL_mixer.h"
+#import "AudioManagerController.h"
 #endif