iosobjective-cmicrophoneavaudiosessionnovocaine

iOS App asks for microphone access, even for kAudioSessionCategory_MediaPlayback


I'm using the Novocaine library from: https://github.com/alexbw/novocaine to playback wav files. I know that iOS has its own media player API however its limitation is in the preset equalizers. I need to use Novocaine because I am using NVDSP https://github.com/bartolsthoorn/NVDSP to implement a 10-band graphic equalizer.

Apple rejected my submitted app because it asks for microphone access but it is only a playback app. They said:

"The microphone consent request is generated by the use of either AVAudioSessionCategoryRecord or AVAudioSessionCategoryPlayAndRecord audio categories"

In Novocaine.m, I modified the setupAudio from

UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord

to each of these:

UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound
UInt32 sessionCategory = kAudioSessionCategory_SoloAmbientSound

but in each of the above cases, the app still requested microphone access.

I searched all the code and this is the only place where the audio session category is set.

To test, after every modification, you have to do this on the iPod:

Settings -> General -> Reset -> Reset Location & Privacy

otherwise the test is not valid.

I single-stepped through almost all of the Novocaine code with the XCode debugger, but it is very difficult to diagnose, because the microphone access popup only shows when the view is displayed, however, the check for it happens much earlier in the code.

Is there any other place in the code that requests microphone access or which affects microphone access as a side-effect?

I'm using XCode 5.0.2 (5A3005) with iOS SDK 7.0, and my only test device is an iPod Touch 5th generation.


Solution

  • Complete credit goes to DMT4u over at Github for this, but yes, his/her solution worked for me! Comment out the following lines:

    UInt32 one = 1;
    CheckError( AudioUnitSetProperty(inputUnit,
    kAudioOutputUnitPropertyEnableIO,
    kAudioUnitScope_Input,
    kInputBus,
    &one,
    sizeof(one)), "Couldn't enable IO on the input scope of output unit");
    

    Source: https://github.com/alexbw/novocaine/issues/76