audio file reading minor improvement

This commit is contained in:
minjaesong
2024-04-06 22:56:12 +09:00
parent cb4462b1ff
commit 3e12966e84

View File

@@ -145,15 +145,17 @@ class MusicContainer(
var start = bytesRead var start = bytesRead
val fullbuf = ByteArray(totalSizeInBytes.toInt())
// make full block copies // make full block copies
for (i in 0 until fullCopyCounts) { if (fullCopyCounts > 0) {
val fullbuf = ByteArray(totalSizeInBytes.toInt())
// only read ONCE, you silly
gdxMusic.forceInvoke<Int>("read", arrayOf(fullbuf)) gdxMusic.forceInvoke<Int>("read", arrayOf(fullbuf))
reset() reset()
System.arraycopy(fullbuf, 0, buffer, start, fullbuf.size) for (i in 0 until fullCopyCounts) {
System.arraycopy(fullbuf, 0, buffer, start, fullbuf.size)
start += totalSizeInBytes.toInt() start += totalSizeInBytes.toInt()
}
} }
// copy the remainders from the start of the samples // copy the remainders from the start of the samples