audio: extract mix render block from update

This commit is contained in:
2026-04-14 16:42:25 +08:00
parent 3e56757910
commit ee03f7035b
3 changed files with 158 additions and 100 deletions

View File

@@ -269,6 +269,32 @@ TEST(AudioSystem, ProcessAudioUsesBackendConfigSampleRateForDirectSubmission) {
system.Shutdown();
}
TEST(AudioSystem, RenderAudioProducesMixedBlockWithoutBackendSubmission) {
AudioSystem& system = AudioSystem::Get();
system.Shutdown();
system.SetMasterVolume(0.5f);
system.SetMuted(false);
system.GetMasterMixer().ClearEffects();
AudioClip clip = CreateMono16Clip({16384}, 4);
AudioSourceComponent source;
source.SetSpatialize(false);
source.SetClip(&clip);
source.Play();
float buffer[1] = {};
system.RenderAudio(buffer, 1, 1, 4);
EXPECT_NEAR(buffer[0], 0.25f, 1e-5f);
EXPECT_EQ(system.GetStats().activeSources, 1u);
EXPECT_EQ(system.GetStats().totalSources, 1u);
source.Stop();
system.SetMasterVolume(1.0f);
system.Shutdown();
}
TEST(AudioSystem, AudioListenerComponentSerializeRoundTripPreservesSettings) {
AudioSystem& system = AudioSystem::Get();
system.Shutdown();