Mix partial stream PCM without copying stale buffer tails
This commit is contained in:
1 parent
7ea8c6527f
commit
aea490d00b
2 files changed
+14
-4
No files matched your search
@@ -7,6 +7,16 @@ import kotlin.math.abs
|
||||
import kotlin.math.sin
|
||||
|
||||
class StreamAudioMixTest {
|
||||
@Test fun reusedPcmOnlyMixesTheNewlyPreparedPrefix() {
|
||||
val mix = StreamMixBuffer()
|
||||
val pcm = ShortArray(960) { 12000 }
|
||||
mix.clear(); assertEquals(480, mix.add(pcm, 480, 120))
|
||||
val output = mix.finish()
|
||||
for (i in output.indices) assertEquals(if (i < 240) 12000 else 0, output[i].toInt())
|
||||
mix.clear(); mix.add(pcm, 480, 0)
|
||||
assertTrue(mix.finish().all { it == 0.toShort() })
|
||||
}
|
||||
|
||||
@Test fun joiningAndResetUseTheirOwnOutputOrigin() {
|
||||
val first = StreamMixTimeline()
|
||||
first.append(0, 480); first.append(480, 480)
|
||||
|
||||
Reference in new issue
Block a user