Changeset c6276be in orbit


Ignore:
Timestamp:
08/09/13 12:34:37 (7 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, Servo, Tab_Interface, pyramid
Children:
28bce14
Parents:
ac33039 (diff), 7945ecb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'origin'

Location:
iOS/Orbit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/SignalConverter.h

    rde10cbc r359a504  
    3232- (BOOL) isBluetoothReady; 
    3333- (BOOL) isVolumeMax; 
     34- (BOOL) isAudioJackPlugged; 
    3435- (void) setYaw:(int)y throttle:(int)t pitch:(int)p; 
    3536- (void) playTestSound; 
  • iOS/Orbit/Orbit/SignalConverter.m

    rde10cbc r7945ecb  
    4646        yaw = 78; 
    4747        pitch = 31; 
     48         
     49        // initialise the audio session - this should only be done once 
     50        AudioSessionInitialize(NULL, NULL, NULL, NULL); 
     51        AudioSessionSetActive(YES); 
    4852    } 
    4953    return self; 
     
    6771        [_delegate appStopped]; 
    6872    } 
     73    AudioSessionSetActive(NO); 
    6974} 
    7075 
     
    139144- (BOOL) isVolumeMax 
    140145{ 
    141     AudioSessionSetActive(YES); 
    142     return 1.0 == [[AVAudioSession sharedInstance] outputVolume]; 
     146    Float32 volume; 
     147    UInt32 dataSize; 
     148    AudioSessionGetPropertySize(kAudioSessionProperty_CurrentHardwareOutputVolume, &dataSize); 
     149    AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, &dataSize, &volume); 
     150    NSLog(@"Volume is %f", volume); 
     151    return 1.0 == volume; 
     152} 
     153 
     154- (BOOL) isAudioJackPlugged 
     155{ 
     156    UInt32 routeSize; 
     157     
     158    // oddly, without calling this method caused an error. 
     159    AudioSessionGetPropertySize(kAudioSessionProperty_AudioRouteDescription, &routeSize); 
     160    CFDictionaryRef desc; // this is the dictionary to contain descriptions 
     161     
     162    // make the call to get the audio description and populate the desc dictionary 
     163    AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &routeSize, &desc); 
     164 
     165    // the dictionary contains 2 keys, for input and output. Get output array 
     166    CFArrayRef outputs = CFDictionaryGetValue(desc, kAudioSession_AudioRouteKey_Outputs); 
     167     
     168    // the output array contains 1 element - a dictionary 
     169    CFDictionaryRef dict = CFArrayGetValueAtIndex(outputs, 0); 
     170     
     171    // get the output description from the dictionary 
     172    CFStringRef output = CFDictionaryGetValue(dict, kAudioSession_AudioRouteKey_Type); 
     173     
     174    /** 
     175     These are the possible output types: 
     176     kAudioSessionOutputRoute_LineOut 
     177     kAudioSessionOutputRoute_Headphones 
     178     kAudioSessionOutputRoute_BluetoothHFP 
     179     kAudioSessionOutputRoute_BluetoothA2DP 
     180     kAudioSessionOutputRoute_BuiltInReceiver 
     181     kAudioSessionOutputRoute_BuiltInSpeaker 
     182     kAudioSessionOutputRoute_USBAudio 
     183     kAudioSessionOutputRoute_HDMI 
     184     kAudioSessionOutputRoute_AirPlay 
     185     */ 
     186 
     187    NSLog(@"Output: %@ is %@", output, kAudioSessionOutputRoute_Headphones); 
     188    return CFStringCompare(output, kAudioSessionOutputRoute_Headphones, 0) == kCFCompareEqualTo; 
    143189} 
    144190 
  • iOS/Orbit/Orbit/controllers/FlightViewController.m

    rde10cbc r359a504  
    142142        [signalConverter stopProcessing]; 
    143143        [self resetViews]; 
    144     } else if (!signalConverter.isVolumeMax) { 
    145         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Turn Up The Volume" message:@"Your device volume must be at the maximum for proper operation" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    146         [alert show]; 
    147     } else if (!signalConverter.isBluetoothReady) { 
    148         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Device not found" message:@"No Bluetooth device detected. Ensure Bluetooth is on and the Mindwave headset is paired" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    149         [alert show]; 
    150     } else if ([signalConverter startProcessing]) { 
    151         [self logMessage:@"Searching for device"]; 
    152         connectButton.title = @"Disconnect"; 
    153144    } else { 
    154         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to connect" message:@"Check the device is correctly paired on Bluetooth" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    155         [alert show]; 
     145        BOOL volumeMax  = [signalConverter isVolumeMax]; 
     146        BOOL headphones = [signalConverter isAudioJackPlugged]; 
     147         
     148        if (!volumeMax && !headphones) { 
     149            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Check Volume & Transmitter" message:@"Ensure the volume is at max and the transmitter is plugged into the headphones" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     150            [alert show]; 
     151        } else if (!volumeMax) { 
     152            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Turn Up The Volume" message:@"Your device volume must be at the maximum for proper operation" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     153            [alert show]; 
     154        } else if (!headphones) { 
     155            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Plug In The Transmitter" message:@"Ensure the infrared transmitter is plugged into the headphone jack" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     156            [alert show]; 
     157        } else if (!signalConverter.isBluetoothReady) { 
     158            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Device not found" message:@"No Bluetooth device detected. Ensure Bluetooth is on and the Mindwave headset is paired" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     159            [alert show]; 
     160        } else if ([signalConverter startProcessing]) { 
     161            [self logMessage:@"Searching for device"]; 
     162            connectButton.title = @"Disconnect"; 
     163        } else { 
     164            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to connect" message:@"Check the device is correctly paired on Bluetooth" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     165            [alert show]; 
     166        } 
    156167    } 
    157168} 
    158169 
    159170- (IBAction) testButtonPressed:(id) sender { 
     171    [signalConverter isAudioJackPlugged]; 
    160172    if (signalConverter.running) { 
    161173        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Stop test sound" message:@"Press Stop first to end the test" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
Note: See TracChangeset for help on using the changeset viewer.