Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ final class AudioFileStreamProcessor {
fillUsedFrames(framesCount: framesAdded)
return
} else if status != 0 {
fileStreamCallback?(.raiseError(.codecError))
raiseCodecError(resetting: converter)
return
}

Expand Down Expand Up @@ -620,7 +620,7 @@ final class AudioFileStreamProcessor {
fillUsedFrames(framesCount: framesAdded)
continue packetProcess
} else if status != 0 {
fileStreamCallback?(.raiseError(.codecError))
raiseCodecError(resetting: converter)
return
}
} else {
Expand Down Expand Up @@ -651,13 +651,24 @@ final class AudioFileStreamProcessor {
fillUsedFrames(framesCount: framesAdded)
continue packetProcess
} else if status != 0 {
fileStreamCallback?(.raiseError(.codecError))
raiseCodecError(resetting: converter)
return
}
}
}
}

/// Resets the converter and raises `.codecError`.
///
/// A failed fill can leave the converter holding a span of `inInputData`, which is freed once the
/// packets proc returns; resetting drops it, as `processSeek()` does.
///
/// - parameter converter: The `AudioConverterRef` that failed.
private func raiseCodecError(resetting converter: AudioConverterRef) {
AudioConverterReset(converter)
fileStreamCallback?(.raiseError(.codecError))
}

/// Fills the `AudioBuffer` with data as required
///
/// - parameter list: An `UnsafeMutableAudioBufferListPointer` object representing the buffer list be filled with data
Expand Down
Loading