project_files/HedgewarsMobile/Classes/ObjcExports.m
author Henek
Mon, 13 Dec 2010 04:53:48 +0100
changeset 4515 9b30be246742
parent 4507 0f9b86942c19
child 4752 d65705a67c4e
permissions -rw-r--r--
my first merge :(
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4028
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     1
/*
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     3
 * Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com>
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     4
 *
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     8
 *
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    13
 *
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    17
 *
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    18
 * File created on 30/10/2010.
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    19
 */
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    20
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    21
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    22
#import "ObjcExports.h"
4362
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    23
#import "AmmoMenuViewController.h"
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
    24
#import "AudioToolbox/AudioToolbox.h"
4028
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    25
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    26
#pragma mark -
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    27
#pragma mark internal variables
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    28
// actual game started (controls should be enabled)
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    29
BOOL gameRunning;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    30
// black screen present
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    31
BOOL savedGame;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    32
// cache the grenade time
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    33
NSInteger grenadeTime;
4362
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    34
// the reference to the newMenu instance
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    35
AmmoMenuViewController *amvc_instance;
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
    36
// the audiosession must be initialized before using properties
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
    37
BOOL gAudioSessionInited = NO;
4028
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    38
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    39
#pragma mark -
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    40
#pragma mark functions called like oop
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    41
void objcExportsInit() {
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 4028
diff changeset
    42
    gameRunning = NO;
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 4028
diff changeset
    43
    savedGame = NO;
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 4028
diff changeset
    44
    grenadeTime = 2;
4028
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    45
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    46
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    47
BOOL inline isGameRunning() {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    48
    return gameRunning;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    49
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    50
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    51
void inline setGameRunning(BOOL value) {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    52
    gameRunning = value;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    53
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    54
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    55
NSInteger cachedGrenadeTime() {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    56
    return grenadeTime;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    57
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    58
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    59
void inline setGrenadeTime(NSInteger value) {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    60
    grenadeTime = value;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    61
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    62
4362
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    63
void inline setAmmoMenuInstance(AmmoMenuViewController *instance) {
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    64
    amvc_instance = instance;
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    65
}
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
    66
4028
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    67
#pragma mark -
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    68
#pragma mark functions called by pascal code
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    69
void startSpinning() {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    70
    gameRunning = NO;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    71
    UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    72
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    73
    indicator.tag = ACTIVITYINDICATOR_TAG;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    74
    int offset;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    75
    if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    76
        offset = -120;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    77
    else
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    78
        offset = 120;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    79
    if (IS_DUALHEAD())
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    80
        indicator.center = CGPointMake(theWindow.frame.size.width/2, theWindow.frame.size.height/2 + offset);
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    81
    else
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    82
        indicator.center = CGPointMake(theWindow.frame.size.width/2 + offset, theWindow.frame.size.height/2);
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    83
    indicator.hidesWhenStopped = YES;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    84
    [indicator startAnimating];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    85
    [theWindow addSubview:indicator];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    86
    [indicator release];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    87
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    88
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    89
void stopSpinning() {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    90
    UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    91
    UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[theWindow viewWithTag:ACTIVITYINDICATOR_TAG];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    92
    [indicator stopAnimating];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    93
    HW_zoomSet(1.7);
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    94
    if (savedGame == NO)
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    95
        gameRunning = YES;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    96
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    97
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
    98
void clearView() {
4504
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
    99
    // don't use any engine calls here as this function is called every time the ammomenu is opened
4028
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   100
    UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   101
    UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   102
    UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   103
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   104
    [UIView beginAnimations:@"remove button" context:NULL];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   105
    [UIView setAnimationDuration:ANIMATION_DURATION];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   106
    theButton.alpha = 0;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   107
    theSegment.alpha = 0;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   108
    [UIView commitAnimations];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   109
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   110
    if (theButton)
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   111
        [theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:ANIMATION_DURATION];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   112
    if (theSegment)
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   113
        [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:ANIMATION_DURATION];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   114
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   115
    grenadeTime = 2;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   116
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   117
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   118
void replayBegan() {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   119
    UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   120
    UIView *blackView = [[UIView alloc] initWithFrame:theWindow.frame];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   121
    blackView.backgroundColor = [UIColor blackColor];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   122
    blackView.alpha = 0.6;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   123
    blackView.tag = REPLAYBLACKVIEW_TAG;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   124
    blackView.exclusiveTouch = NO;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   125
    blackView.multipleTouchEnabled = NO;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   126
    blackView.userInteractionEnabled = NO;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   127
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   128
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   129
    indicator.center = theWindow.center;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   130
    [indicator startAnimating];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   131
    [blackView addSubview:indicator];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   132
    [indicator release];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   133
    [theWindow addSubview:blackView];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   134
    [blackView release];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   135
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   136
    savedGame = YES;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   137
    stopSpinning();
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   138
}
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   139
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   140
void replayFinished() {
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   141
    UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   142
    UIView *blackView = (UIView *)[theWindow viewWithTag:REPLAYBLACKVIEW_TAG];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   143
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   144
    [UIView beginAnimations:@"removing black" context:NULL];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   145
    [UIView setAnimationDuration:1];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   146
    blackView.alpha = 0;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   147
    [UIView commitAnimations];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   148
    [theWindow performSelector:@selector(removeFromSuperview) withObject:blackView afterDelay:1];
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   149
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   150
    gameRunning = YES;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   151
    savedGame = NO;
eb371ada631d move functions called by pascal code outside controller
koda
parents:
diff changeset
   152
}
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 4028
diff changeset
   153
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 4028
diff changeset
   154
void updateVisualsNewTurn(void) {
4362
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
   155
    DLog(@"updating visuals");
8dae325dc625 added missing graphics and fixed some glitches/crashes/bugs
koda
parents: 4034
diff changeset
   156
    [amvc_instance updateAmmoVisuals];
4034
634a8c8682de add some phone rumbling to big explosions, airbomb and sinegun
koda
parents: 4028
diff changeset
   157
}
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   158
4507
0f9b86942c19 audio_session is giving problems with multitasking so disabling it for now
koda
parents: 4504
diff changeset
   159
/*
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   160
// http://stackoverflow.com/questions/287543/how-to-programatically-sense-the-iphone-mute-switch
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   161
BOOL isAppleDeviceMuted(void) {
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   162
    if (!gAudioSessionInited) {
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   163
        AudioSessionInterruptionListener inInterruptionListener = NULL;
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   164
        OSStatus error;
4507
0f9b86942c19 audio_session is giving problems with multitasking so disabling it for now
koda
parents: 4504
diff changeset
   165
        if ((error = AudioSessionInitialize(NULL, NULL, inInterruptionListener, NULL)))
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   166
            DLog(@"*** Error *** error in AudioSessionInitialize: %d", error);
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   167
        else
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   168
            gAudioSessionInited = YES;
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   169
    }
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   170
    UInt32 propertySize = sizeof(CFStringRef);
4504
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
   171
    BOOL muteResult = NO;
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   172
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   173
    // this checks if there is volume
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   174
    Float32 volume;
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   175
    OSStatus n = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, &propertySize, &volume);
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   176
    if (n != 0)
4488
e83216eba1db forgot to update these files
koda
parents: 4461
diff changeset
   177
        DLog( @"AudioSessionGetProperty 'volume': %d", n );
4507
0f9b86942c19 audio_session is giving problems with multitasking so disabling it for now
koda
parents: 4504
diff changeset
   178
    BOOL volumeResult = (volume == 0.0f);
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   179
    
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   180
    // this checks if the device is muted
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   181
    CFStringRef state;
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   182
    n = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   183
    if (n != 0)
4488
e83216eba1db forgot to update these files
koda
parents: 4461
diff changeset
   184
        DLog( @"AudioSessionGetProperty 'audioRoute': %d", n );
4504
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
   185
    else {
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
   186
        NSString *result = (NSString *)state;
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
   187
        muteResult = ([result length] == 0);
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
   188
        releaseAndNil(result);
8906b2409d97 add the appirater class for getting more positive reviews
koda
parents: 4488
diff changeset
   189
    }
4461
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   190
    return volumeResult || muteResult;
2f4f5d649bcd add a simple check to prevent loading sounds when device is muted
koda
parents: 4362
diff changeset
   191
}
4507
0f9b86942c19 audio_session is giving problems with multitasking so disabling it for now
koda
parents: 4504
diff changeset
   192
*/