diff --git a/AudioStreaming/Streaming/AudioPlayer/AudioPlayer.swift b/AudioStreaming/Streaming/AudioPlayer/AudioPlayer.swift index 13fba34..a17d0d0 100644 --- a/AudioStreaming/Streaming/AudioPlayer/AudioPlayer.swift +++ b/AudioStreaming/Streaming/AudioPlayer/AudioPlayer.swift @@ -225,6 +225,10 @@ open class AudioPlayer { } deinit { + // The IO thread keeps pulling from the render callback until the hardware is stopped, + // so stop it before the buffers it renders into are freed. + player.auAudioUnit.stopHardware() + audioEngine.stop() playerContext.audioPlayingEntry?.close() clearQueue() rendererContext.clean()