Repository navigation
Conversation
|
See also: #14203 |
ada5f05 to
fde2e47
Compare
Thanks for the pointer. I compared this with the previous SampleDataEvent work. The regression test now covers the key Flash behaviors, including ByteArray reuse, varying block sizes, stream completion, stop/stopAll, multiple sounds, startTime offsets, generated-sound lifecycle, and the 32-sound limit. The comparison also caught one missing behavior here: after a Sound becomes generated, load() must throw Error #2037. I verified this in Flash and updated the implementation/test accordingly. The main remaining difference is callback scheduling before Sound.play() returns, which appears timing/buffering-dependent in Flash, so this PR does not hardcode a fixed callback count. |
|
I will close this since there is already older PR for this. |
Description
Previously, Ruffle did not support AVM2 dynamically generated audio through
SampleDataEvent.SAMPLE_DATA. The callback could run, but the generated samples were not sent to the audio mixer, so tools such as SiON/VMML were silent.This PR adds dynamic
SampleDataEventaudio support by:dispatching
SAMPLE_DATAevents for dynamicSoundobjectsreading generated stereo
float32samples from the callbackByteArrayfeeding them into the audio mixer at 44.1 kHz
tracking sample positions and
startTimesupporting short final blocks,
SOUND_COMPLETE,SoundChannel.stop(),SoundMixer.stopAll(), and multiple dynamic soundsThe behavior was compared against Adobe Flash Player. Stable observable behavior now matches Flash, including sample positions,
ByteArrayreuse, varying block sizes, stream completion, stereo output, multiple sounds, andstartTimeoffsets.One timing-dependent difference remains: Flash may request multiple
SAMPLE_DATAblocks beforeSound.play()returns. This varies with buffering/platform timing, so Ruffle intentionally does not hardcode a fixed number of synchronous callbacks.The VMML reproduction from #20302 was also tested with a locally built Ruffle browser extension, and the Play button now works with music playback.
Fixes #20302
Testing
Added a new AVM2 SWF regression test:
tests/tests/swfs/avm2/sound_sample_data/Its expected output was generated from Adobe Flash Player.
Checks run successfully:
cargo check -p ruffle_corecargo test -p tests --test tests -- sound_sample_data --nocapturegit diff --checkExisting related AVM2 sound tests and a broader sound regression sweep were also run successfully.
Checklist