Description
Godot version:
v3.1.1.stable.official
OS/device including version:
iOS 13.1
Issue description:
The audio input (Microphone) on iOS hardware does not work. It works on the simulator.
There are three separate issues causing this:
-
no microphone permission string in info.plist in XCode export by default (already reported in issue iOS export does not declare microphone permission #30307)
-
the incorrect AVAudioSession.AudioSessionCategory is set at startup in app_delegate.mm. It works when changed to AVAudioSessionCategoryPlayAndRecord, ie:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
Maybe this should be configurable from the Godot export settings, or inferred from the sound bus usage? -
a "-50" error from AudioUnitRender in audio_driver_coreaudio.cpp whenever microphone input is enabled. This is because bufferList.mBuffers[0].mDataByteSize is too small, since there is a mismatch between the capture buffer format and the audio device.
Steps to reproduce:
- Download minimal reproduction project below
- Disable mute on the bus panel in Godot to ensure audio input and output occurs simultaneously.
- Export to iOS build
- Install .ipa on iOS hardware, and the app will fail to start or record.
- Open XCode and install on simulator - observe that audio recording works properly.
Minimal reproduction project:
This project will trigger it on iOS hardware (but works fine on the simulator). You may need to unmute audio on the "Record" bus, so that audio is input and output simultaneously:
https://github.com/godotengine/godot-demo-projects/tree/master/audio/mic_record