Recording from Viewcontroller vs A Model Class

若如初见. 提交于 2019-12-12 05:38:33

问题


Please refer to this post for code.

How can recording from the Viewcontroller (Main thread) and recording from a model class be different? I tried calling DispatchQueue.main.async {} but the audio data is always 44 bytes no matter how long i recorder which is not correct.

Working Implementation: ViewControllers calls SpeechRecorder.startRecording()

Desired Implementation, ViewController calls Model.tryRecording() which then results in Model calling SpeechRecorder.startRecording()

Any suggestions?

Thanks in advance -Lu


回答1:


Found Error was NOT with threads or (ViewController vs Model) but with mixing AVFoundation and AudioToolBox/CoreAudio Frameworks.

The Model was Playing an audio clip (using AVFoundation). When it finishes playing the audio, the model would call the recorder to start recording.(Using AudioToolbox and CoreAudio).

This was affecting the Recording.



来源:https://stackoverflow.com/questions/40595382/recording-from-viewcontroller-vs-a-model-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!