fix(custom-playback-speed): implement own method instead of takeWhile

This commit is contained in:
oSumAtrIX 2022-09-22 08:38:49 +02:00
parent 5462afe7c4
commit 8522d4cd70
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -88,7 +88,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
"sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType"
)
val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!!;
val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!!
val limiterMethodImpl = limiterMethod.implementation!!
val (limiterMinConstIndex, limiterMinConst) = limiterMethodImpl.instructions.withIndex()
@ -123,11 +123,16 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
.div(stepsGranularity)// round to nearest multiple of stepsGranularity
.coerceAtLeast(1 / stepsGranularity) // ensure steps are at least 1/8th of the step granularity
val videoSpeedsArray = DoubleStream
val videoSpeedsArray = buildList<Number> {
DoubleStream
.iterate(speedLimitMin.toDouble()) { it + step } // create a stream of speeds
.takeWhile { it <= speedLimitMax } // limit the stream to the max speed
.mapToObj { it.toFloat().toRawBits() }
.toList() as List<Number>
.let { speedStream ->
for (speed in speedStream) {
if (speed > speedLimitMax) break
add(speed.toFloat().toRawBits())
}
}
}
// adjust the new array of speeds size
constructor.replaceInstruction(