问题
i'm working on an app that records sound. furthermore, i want the user to be able to comment certain situations with his own voice. i thought it would be sufficient to configure one audio session and just create two AVAudioRecorder instances with different file URLs. but that doesn't work, the second audio recorder does create its audio file, but it doesn't record any sound.
does anyone know how to realize two AVAudioRecorder instances that actually work on one device?
recording with only one AVAudioRecorder works, but using both doesn't work.
i have a workaround in mind, but that's a bunch of code i would like to avoid at the moment...
thanks!
回答1:
figured the problem out: the audio session is not the problem, it's the audio format.
if you want to record into multiple files using multiple AVAudioRecorders, you have to use uncompressed audio format(s). i assume the HW assisted encoding is used by one AVAudioRecorder and thus every further AVAudioRecorder can't use it simultaniously.
one AVAudioRecorder using a compressed format (e.g. kAudioFormatMPEG4AAC) works fine, but every further recorder has to use an uncompressed audio format. if all AVAudioRecorder instances use a uncompressed format (e.g. kAudioFormatLinearPCM) it also works.
来源:https://stackoverflow.com/questions/8492818/multiple-avaudiorecorder-instances