mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 09:07:46 +01:00
fix(custom-playback-speed): implement own method instead of takeWhile
This commit is contained in:
parent
5462afe7c4
commit
8522d4cd70
1 changed files with 11 additions and 6 deletions
|
@ -88,7 +88,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
|
||||||
"sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType"
|
"sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType"
|
||||||
)
|
)
|
||||||
|
|
||||||
val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!!;
|
val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!!
|
||||||
val limiterMethodImpl = limiterMethod.implementation!!
|
val limiterMethodImpl = limiterMethod.implementation!!
|
||||||
|
|
||||||
val (limiterMinConstIndex, limiterMinConst) = limiterMethodImpl.instructions.withIndex()
|
val (limiterMinConstIndex, limiterMinConst) = limiterMethodImpl.instructions.withIndex()
|
||||||
|
@ -123,11 +123,16 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
|
||||||
.div(stepsGranularity)// round to nearest multiple of stepsGranularity
|
.div(stepsGranularity)// round to nearest multiple of stepsGranularity
|
||||||
.coerceAtLeast(1 / stepsGranularity) // ensure steps are at least 1/8th of the step granularity
|
.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
|
.iterate(speedLimitMin.toDouble()) { it + step } // create a stream of speeds
|
||||||
.takeWhile { it <= speedLimitMax } // limit the stream to the max speed
|
.let { speedStream ->
|
||||||
.mapToObj { it.toFloat().toRawBits() }
|
for (speed in speedStream) {
|
||||||
.toList() as List<Number>
|
if (speed > speedLimitMax) break
|
||||||
|
add(speed.toFloat().toRawBits())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// adjust the new array of speeds size
|
// adjust the new array of speeds size
|
||||||
constructor.replaceInstruction(
|
constructor.replaceInstruction(
|
||||||
|
|
Loading…
Reference in a new issue