开发者

Simultaneous record and play from same file

开发者 https://www.devze.com 2022-12-17 09:41 出处:网络
I\'m attempting to use Audio Queue Services for the first time. After reading all the documentation and playing with some sample code, I think I understand the classes pretty well and have implemented

I'm attempting to use Audio Queue Services for the first time. After reading all the documentation and playing with some sample code, I think I understand the classes pretty well and have implemented my own playback and recording appli开发者_开发技巧cation without any problems.

I need to simultaneously record and play from the same buffer, but I'm having some significant difficulty writing to a file and reading from the file at the same time. I can get the file to be played back with no problem but only for the last written buffer before the playing started. I'm hoping it's possible to continue to playback the file for as long as it's being written to. Is this possible?

Thanks in advance!


It might be worthwhile to save the captured data in your own buffers instead of writing to a file. You can then supply these buffers to the playback.

Please make sure that you add the following line from AVFoundation framework for simultaneous capture and playback:

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:nil];

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号