 		})
 
 		DispatchQueue.global().async {
-			while let data = self.read(maxBytes: 4 * 1024) {
+			while !tokenSource.isCancellationRequested && self.isValid, let data = self.read(maxBytes: 4 * 1024) {
 				try! parse(data)
 			}
 		}

import AudioToolbox
import Foundation
import Sockets
import Streams


{
	public func createAudioStream() -> ReadableStream<AudioData>
	{
		let tokenSource = CancellationTokenSource()
		let stream = Streams.Stream<AudioData>()
		stream.addDownstreamDisposable(Scope {
			tokenSource.cancel()
		})

		var description: AudioStreamBasicDescription? = nil

		let parse = try! AFSUtility.CreateCustomAudioStreamParser(
