fix seek crash: Double value gets infinit and can't be converted to Int64 (#115)

* fix seek crash: Double value get infinit and can't be converted to Int64

* add CoreAudio import to be able to build for macOS Catalyst
This commit is contained in:
Maximilian Bauer
2025-10-13 18:32:34 +03:00
committed by GitHub
parent 69dc0d631c
commit bccfc20403
@@ -6,6 +6,7 @@
//
import AVFoundation
import CoreAudio
enum AudioConvertStatus: Int32 {
case done = 100
@@ -104,6 +105,8 @@ final class AudioFileStreamProcessor {
let dataLengthInBytes = Double(readingEntry.audioDataLengthBytes())
let entryDuration = readingEntry.duration()
let duration = entryDuration < readingEntry.progress && entryDuration > 0 ? readingEntry.progress : entryDuration
guard duration > 0.0 else { return }
var seekByteOffset = Int64(dataOffset + (readingEntry.seekRequest.time / duration) * dataLengthInBytes)