AVFAudio - Is it safe to perform file copy immediately after AVAudioRecorder.stop()

We start a voice recording via

self.avAudioRecorder = try AVAudioRecorder(
    url: self.recordingFileUrl, 
    settings: settings
)
self.avAudioRecorder.record()

At certain point, we will stop the recording via

self.avAudioRecorder.stop()

I was wondering, is it safe to perform file copy on self.recordingFileUrl immediately, after self.avAudioRecorder.stop()?

Is all recording data has been flushed to self.recordingFileUrl and self.recordingFileUrl file is closed properly?

Answered by DTS Engineer in 712578022

Hello,

It does seem to be synchronous, though in theory something could still fail at that point, so it is safer to use the delegate method audioRecorderDidFinishRecording(_:successfully:), rather than make an assumption that the recording will always succeed after calling stop.

Accepted Answer

Hello,

It does seem to be synchronous, though in theory something could still fail at that point, so it is safer to use the delegate method audioRecorderDidFinishRecording(_:successfully:), rather than make an assumption that the recording will always succeed after calling stop.

AVFAudio - Is it safe to perform file copy immediately after AVAudioRecorder.stop()
 
 
Q