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:
parent
d42f5970f1
commit
277e5a151f
1 changed files with 3 additions and 4 deletions
|
@ -226,10 +226,9 @@ class ReplayGainAudioProcessor : BaseAudioProcessor() {
|
|||
val buffer = replaceOutputBuffer(size)
|
||||
|
||||
if (volume == 1f) {
|
||||
// Nothing to do, just copy the bytes into the output buffer.
|
||||
for (i in position until limit) {
|
||||
buffer.put(inputBuffer[i])
|
||||
}
|
||||
// No need to apply ReplayGain, do a memmove using put instead of
|
||||
// a for loop (the latter is not efficient)
|
||||
buffer.put(inputBuffer.slice())
|
||||
} else {
|
||||
for (i in position until limit step 2) {
|
||||
// Ensure we clamp the values to the minimum and maximum values possible
|
||||
|
|
Loading…
Reference in a new issue