project_files/HedgewarsMobile/Classes/ObjcExports.m
changeset 4504 8906b2409d97
parent 4488 e83216eba1db
child 4507 0f9b86942c19
equal deleted inserted replaced
4503:a8ab151bcae3 4504:8906b2409d97
    94     if (savedGame == NO)
    94     if (savedGame == NO)
    95         gameRunning = YES;
    95         gameRunning = YES;
    96 }
    96 }
    97 
    97 
    98 void clearView() {
    98 void clearView() {
       
    99     // don't use any engine calls here as this function is called every time the ammomenu is opened
    99     UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
   100     UIWindow *theWindow = (IS_DUALHEAD()) ? [SDLUIKitDelegate sharedAppDelegate].uiwindow : [[UIApplication sharedApplication] keyWindow];
   100     UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
   101     UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
   101     UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
   102     UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
   102 
   103 
   103     [UIView beginAnimations:@"remove button" context:NULL];
   104     [UIView beginAnimations:@"remove button" context:NULL];
   164             DLog(@"*** Error *** error in AudioSessionInitialize: %d", error);
   165             DLog(@"*** Error *** error in AudioSessionInitialize: %d", error);
   165         else
   166         else
   166             gAudioSessionInited = YES;
   167             gAudioSessionInited = YES;
   167     }
   168     }
   168     UInt32 propertySize = sizeof(CFStringRef);
   169     UInt32 propertySize = sizeof(CFStringRef);
       
   170     BOOL muteResult = NO;
   169 
   171 
   170     // this checks if there is volume
   172     // this checks if there is volume
   171     Float32 volume;
   173     Float32 volume;
   172     OSStatus n = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, &propertySize, &volume);
   174     OSStatus n = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, &propertySize, &volume);
   173     if (n != 0)
   175     if (n != 0)
   177     // this checks if the device is muted
   179     // this checks if the device is muted
   178     CFStringRef state;
   180     CFStringRef state;
   179     n = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
   181     n = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
   180     if (n != 0)
   182     if (n != 0)
   181         DLog( @"AudioSessionGetProperty 'audioRoute': %d", n );
   183         DLog( @"AudioSessionGetProperty 'audioRoute': %d", n );
   182     NSString *result = (NSString *)state;
   184     else {
   183     BOOL muteResult = ([result length] == 0);
   185         NSString *result = (NSString *)state;
   184     releaseAndNil(result);
   186         muteResult = ([result length] == 0);
   185     
   187         releaseAndNil(result);
       
   188     }
   186     return volumeResult || muteResult;
   189     return volumeResult || muteResult;
   187 }
   190 }