This commit is contained in:
Ali
2021-09-03 00:45:22 +04:00
parent 8aefa19d31
commit 1fe0d4a75b
53 changed files with 489 additions and 566 deletions

View File

@@ -46,7 +46,9 @@ private final class MediaBoxFileMap {
var data = Data(count: Int(4 + count * 2 * 4))
let dataCount = data.count
if !(data.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<UInt8>) -> Bool in
if !(data.withUnsafeMutableBytes { rawBytes -> Bool in
let bytes = rawBytes.baseAddress!.assumingMemoryBound(to: UInt8.self)
guard fd.read(bytes, dataCount) == dataCount else {
return false
}
@@ -337,8 +339,6 @@ final class MediaBoxPartialFile {
} else {
assertionFailure()
}
} catch {
assertionFailure()
}
}
@@ -364,7 +364,9 @@ final class MediaBoxPartialFile {
assert(self.queue.isCurrent())
self.fd.seek(position: Int64(offset))
let written = data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Int in
let written = data.withUnsafeBytes { rawBytes -> Int in
let bytes = rawBytes.baseAddress!.assumingMemoryBound(to: UInt8.self)
return self.fd.write(bytes.advanced(by: dataRange.lowerBound), count: dataRange.count)
}
assert(written == dataRange.count)
@@ -457,7 +459,8 @@ final class MediaBoxPartialFile {
self.fd.seek(position: Int64(actualRange.lowerBound))
var data = Data(count: actualRange.count)
let dataCount = data.count
let readBytes = data.withUnsafeMutableBytes { (bytes: UnsafeMutablePointer<Int8>) -> Int in
let readBytes = data.withUnsafeMutableBytes { rawBytes -> Int in
let bytes = rawBytes.baseAddress!.assumingMemoryBound(to: Int8.self)
return self.fd.read(bytes, dataCount)
}
if readBytes == data.count {