Skip to content

Commit

Permalink
Audio decoder restart if error occured
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kh committed Jun 28, 2017
1 parent 01931eb commit 4c7cc34
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apple/Common/IO/AudioDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,24 @@ class AudioDecoder : AudioOutputProtocol, IOSessionProtocol {
if pcmBufferList != nil {
free(pcmBufferList!.mBuffers.mData)
pcmBufferList = nil
pcmDataSize = 0
}
}
catch {
logIOError(error)
}
}

func restart() {
do {
stop()
try start()
}
catch {
logIOError(error)
}
}

func process(_ packet: AudioData) {

guard let converter = self.converter else { return }
Expand Down Expand Up @@ -91,6 +102,7 @@ class AudioDecoder : AudioOutputProtocol, IOSessionProtocol {
}
catch {
logIOError(error)
restart()
}
}

Expand Down

0 comments on commit 4c7cc34

Please sign in to comment.