From 2d1031b7b9accc1d49fb42a7d1de504c6d38e368 Mon Sep 17 00:00:00 2001 From: TibixDev Date: Thu, 8 Oct 2026 09:44:32 +0300 Subject: [PATCH] test(ngs2): cover append boundaries and missing waveform metadata --- .../libSceNgs2.native/tests/Ngs2Atrac9.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/core/libs/prx/libSceNgs2.native/tests/Ngs2Atrac9.cpp b/core/libs/prx/libSceNgs2.native/tests/Ngs2Atrac9.cpp index 71e309c3a..a6e94c2a9 100644 --- a/core/libs/prx/libSceNgs2.native/tests/Ngs2Atrac9.cpp +++ b/core/libs/prx/libSceNgs2.native/tests/Ngs2Atrac9.cpp @@ -446,6 +446,41 @@ static void TestStarvationAndTruncation(const std::vector& reference) { } } +static void TestAppendBoundaries(const std::vector& reference) { + for (std::uint32_t split = 1; split < SuperframeBytes; ++split) { + const auto system = CreateSystem(); + const auto voice = EmptySampler(system); + Queue(voice, Superframe, split, SCE_NGS2_WAVEFORM_BLOCKS_FLAG_CONTINUE, 500, 100); + for (float value : Render(system, Grain)) Require(value == 0.0f); + const Ngs2WaveformBlock block{split, SuperframeBytes - split, UINT32_MAX, UINT32_MAX, UINT32_MAX, 0, 0}; + Control(voice, SCE_NGS2_SAMPLER_VOICE_PARAM_ADD_WAVEFORM_BLOCKS, + Ngs2SamplerVoiceWaveformBlocksParam{{}, Superframe, SCE_NGS2_WAVEFORM_BLOCKS_FLAG_APPEND, 1, &block}); + const auto output = Render(system, 512); + for (std::size_t i = 0; i < output.size(); ++i) Require(output[i] == (i < 500 ? reference[100 + i] : 0.0f)); + Ngs2SamplerVoiceState state{}; + Require(sceNgs2VoiceGetState(voice, &state.voice_state, sizeof(state)) == SCE_NGS2_OK); + Require(state.num_decoded_samples == 500 && state.decoded_data_size == SuperframeBytes); + Require(state.waveform_data == Superframe + SuperframeBytes && Flags(voice) == 0); + Require(sceNgs2SystemDestroy(system, nullptr) == SCE_NGS2_OK); + } +} + +static void TestAppendWithoutWaveform() { + const auto system = CreateSystem(); + const auto voice = EmptySampler(system); + bool rejected = false; + try { + Queue(voice, Superframe, SuperframeBytes, SCE_NGS2_WAVEFORM_BLOCKS_FLAG_APPEND, 500); + } catch (const std::invalid_argument&) { + rejected = true; + } + Require(rejected); + Queue(voice, Superframe, SuperframeBytes, 0, 500); + Render(system, 512); + Require(Flags(voice) == 0); + Require(sceNgs2SystemDestroy(system, nullptr) == SCE_NGS2_OK); +} + int main() { const auto reference = Reference(); TestSkipAndBlockEnd(reference); @@ -458,5 +493,7 @@ int main() { TestStreamPartitions(); TestRefill(reference); TestStarvationAndTruncation(reference); + TestAppendBoundaries(reference); + TestAppendWithoutWaveform(); return 0; }