An audio engine graph that uses a AVAudioPlayerNode connected to the AVAudioEngine for audio playback generates a lot of "throwing -10878" messages.
Simple code to reproduce the error messages (substitute "music.mp3" with anything available):
class ViewController: UIViewController {
var audioEngine: AVAudioEngine = AVAudioEngine()
var player: AVAudioPlayerNode = AVAudioPlayerNode()
override func viewDidLoad() {
super.viewDidLoad()
audioFilePlayback(from: "music", withExtension: "mp3")
}
func audioFilePlayback(from file: String, withExtension: String) {
do {
let audioFile = try AVAudioFile(forReading: Bundle.main.url(forResource: file, withExtension: withExtension)!)
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
try AVAudioSession.sharedInstance().setActive(true)
audioEngine.attach(player)
audioEngine.connect(player, to: audioEngine.mainMixerNode, format: audioFile.processingFormat)
player.scheduleFile(audioFile, at: AVAudioTime(hostTime: 0), completionHandler: nil)
try audioEngine.start()
player.play()
} catch {
print(error.localizedDescription)
}
}
}
Your own "AVAEMixerSample sample code" will do also.
Googling "-10878" by using https://www.osstatus.com/search/results?platform=all&framework=all&search=-10878 indicates that kAudioUnitErr_InvalidParameter has gone wrong.
Can you shed some light on this issue - what is wrong and how can it be avoided.
Thank you.