playback: use more efficient no-op w/replaygain
When ReplayGain is not needed, use ByteBuffer.put in favor of a for loop when doing a simple copy. ByteBuffer.put is highly optimized and far more efficient than a for loop.
This commit is contained in:
@@ -226,10 +226,9 @@ class ReplayGainAudioProcessor : BaseAudioProcessor() {
|
|||||||
val buffer = replaceOutputBuffer(size)
|
val buffer = replaceOutputBuffer(size)
|
||||||
|
|
||||||
if (volume == 1f) {
|
if (volume == 1f) {
|
||||||
// Nothing to do, just copy the bytes into the output buffer.
|
// No need to apply ReplayGain, do a memmove using put instead of
|
||||||
for (i in position until limit) {
|
// a for loop (the latter is not efficient)
|
||||||
buffer.put(inputBuffer[i])
|
buffer.put(inputBuffer.slice())
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (i in position until limit step 2) {
|
for (i in position until limit step 2) {
|
||||||
// Ensure we clamp the values to the minimum and maximum values possible
|
// Ensure we clamp the values to the minimum and maximum values possible
|
||||||
|
|||||||
Reference in New Issue
Block a user