Question

Faced with two errors.

This code worked in iOS 4 and 5, but after update to 6, it is not working (

I found following, but don't know how to fix it in the code.

Beginning in iOS 6, apps need to have the audio key in their UIBackgroundModes in order to use CoreMIDI’s MIDISourceCreate and MIDIDestinationCreate functions. Without the key set, these functions will return kMIDINotPermitted (-10844).

2012-09-23 03:40:04.773 MidiStudio[1017:907] Error (Create MIDI virtual source): -10844:Error Domain=NSMachErrorDomain Code=-10844 "The operation couldn’t be completed. (Mach error -10844.)"

2012-09-23 03:40:04.777 MidiStudio[1017:907] Error (Create MIDI virtual destination): -10844:Error Domain=NSMachErrorDomain Code=-10844 "The operation couldn’t be completed. (Mach error -10844.)"

Here is code for 'source':

-(void)setVirtualSourceEnabled:(BOOL)virtualSourceEnabled {
    if ( virtualSourceEnabled == self.virtualSourceEnabled ) return;

    if ( virtualSourceEnabled ) {
        NSString *name = virtualEndpointName ? virtualEndpointName : [[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString*)kCFBundleNameKey];

        OSStatus s = MIDISourceCreate(client, (CFStringRef)name, &virtualSourceEndpoint);
        NSLogError(s, @"Create MIDI virtual source");
        if ( s != noErr ) return;

        virtualSourceDestination = [[PGMidiVirtualSourceDestination alloc] initWithMidi:self endpoint:virtualSourceEndpoint];

        [delegate midi:self destinationAdded:virtualSourceDestination];
        [[NSNotificationCenter defaultCenter] postNotificationName:PGMidiDestinationAddedNotification
                                                            object:self 
                                                          userInfo:[NSDictionary dictionaryWithObject:virtualSourceDestination
                                                                                               forKey:PGMidiEndpointKey]];

    } else {
        [delegate midi:self destinationRemoved:virtualSourceDestination];

        [[NSNotificationCenter defaultCenter] postNotificationName:PGMidiDestinationRemovedNotification
                                                            object:self 
                                                          userInfo:[NSDictionary dictionaryWithObject:virtualSourceDestination
                                                                                               forKey:PGMidiEndpointKey]];

        [virtualSourceDestination release]; virtualSourceDestination = nil;
        OSStatus s = MIDIEndpointDispose(virtualSourceEndpoint);
        NSLogError(s, @"Dispose MIDI virtual source");
        virtualSourceEndpoint = NULL;
    }
}
Was it helpful?

Solution

[Just putting my notes here on Kurt's excellent answer.]

First off, this is all mentioned in the document called "iOS 6.0 Release Notes." The line there says:

Beginning in iOS 6, apps need to have the audio key in their UIBackgroundModes in order to use CoreMIDI’s MIDISourceCreate and MIDIDestinationCreate functions. Without the key set, these functions will return kMIDINotPermitted (-10844).

So the only thing you need to do (again, just specifying what Kurt answered) is something like this in each target's plist:

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
</array>

OTHER TIPS

You don't need to change any code. Read that message again:

Beginning in iOS 6, apps need to have the audio key in their UIBackgroundModes

UIBackgroundModes is a key in your application's Info.plist. So use Xcode to edit your app's Info.plist, and make the value for that key be an array containing the string audio.

My app uses the MIDIDestinationCreate to play a midi file and the app review team are indeed creating a stink. They insist that the app must play some audio in the background. They quote "2.16: Multitasking Apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc."

I've referred them to the iOS6 release notes mentioned here and they just keep coming back saying it must play audio in the background.

I've submitted a request to Apple Developer Technical Support. Hopefully they will change the app review guidelines which their team follow.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top