[IOS]AudioCaptureCrash (AudioCaptureAudioUnit) 4.27 source

I made a game with a pawn that uses AudioCapture
Android: Everythink ok
Windows Everything OK
IOS: AudioCapture always capture 0 data and when you change scene or close the app, it crashes all . If i load the pawn with the Audio CaptureComponent and i capture nothing, just stay there and then change level, or exit app, the game crash anyways.
any solution? according to UE4 git source ios should be supported using AudioCaptureAudioUnit
Search · AudioCaptureAudioUnit (github.com)

My app is requesting permissions with plist and making a function call (the prompt window appears at the beginning), but just the presence of the component makes everthing collapses

any help with this? i need to solve it for my job

Did you solve this? I’m running in to a similar issue

i had to create my own solution using IOS native code

Thanks for the reply.
If you don’t mind sharing, which Apple API did use? The higher level AVAudioSession, so you recorded to a file, or did you use AudioUnits to get the buffer data? Any tips?

i used AVAudioSession. first i created a small project for ios in Xcode and tested the recording. Then when it work, i move the code as plugin for UE4
somehing like this


@implementation FIosVoiceRecorder
@synthesize recorder,recorderSettings,recorderFilePath,fileUrl;
@synthesize audioPlayer,audioFileName, filePath;

- (instancetype)init
 {
     self = [super init];
     
     return self;
 }
#pragma mark - Audio Recording
- (void)startRecording
{
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    NSError *err = nil;
    [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
    if(err)
    {
        NSLog(@"audioSession: %@ %ld %@", [err domain], (long)[err code], [[err userInfo] description]);
        return;
    }
    [audioSession setActive:YES error:&err];
    err = nil;
    if(err)
    {
        NSLog(@"audioSession: %@ %ld %@", [err domain], (long)[err code], [[err userInfo] description]);
        return;
    }
    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *docsDir = [dirPaths objectAtIndex:0];
     fileUrl = [NSURL fileURLWithPath:[docsDir stringByAppendingPathComponent:@"Mustakistmp.m4a"]];
   
   // NSURL *tmpFileUrl = [[NSURL alloc] initFileURLWithPath:filePath];
    //fileUrl = [[NSURL alloc] initFileURLWithPath:filePath];

    NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                            [NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
                            [NSNumber numberWithFloat:16000.0], AVSampleRateKey,
                            [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                            nil];
    
     
    
     err = nil;
    recorder = [[ AVAudioRecorder alloc] initWithURL:fileUrl settings:recordSettings error:&err];
    if(!recorder){
        NSLog(@"recorder: %@ %ld %@", [err domain], (long)[err code], [[err userInfo] description]);
        
        return;
    }
    
    //prepare to record
    [recorder setDelegate:self];
    [recorder prepareToRecord];
    recorder.meteringEnabled = YES;
    
    BOOL audioHWAvailable = audioSession.isInputAvailable;
    if (! audioHWAvailable) {
        NSLog(@"Audio input hardware not available");
     
        return;
    }
    
    // start recording
    [recorder recordForDuration:(NSTimeInterval) 60];//Maximum recording time : 60 seconds default
   
    NSLog (@"Recroding Started: %@ ",fileUrl.absoluteString);

}

- (void)stopRecording
{
    [recorder stop];
    NSLog(@"Recording Stopped");
}
#pragma mark - Audio Playing
- (void)startPlaying
{
    NSLog(@"playRecording");
        
        AVAudioSession *audioSession = [AVAudioSession sharedInstance];
        [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
        
        NSError *error;
        audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error];
        audioPlayer.numberOfLoops = 0;
        [audioPlayer play];
        NSLog(@"playing");
}

this is not the complete code so it won’t correctly but i hope you get the idea.

Yes that makes sense, thank you!

No problem