3.0.6: Crash in simulator and device when calling SamplePlayer->setSample

We were able to reproduce an intermittent crash we’ve been seeing by setting up a bunch of SamplePlayers and calling setSource() (+ play()) on them while they are playing. Attached is a proof-of-concept which is basically just that with 100 players. It crashes for me within 10 seconds on both device and macOS simulator (all SDK/OS 3.0.6), usually with a segmentation fault in the audio thread rendering a SamplePlayer. It also crashes for me if I only have 1 player but it takes much longer. Seems to happen for uncompressed or ADPCM audio samples.

playdate-sampleplayer-rate-repro.zip (14.3 KB)

I’ve also confirmed that calling stop() on the player first prevents this crash.

For posterity, this still seems to exist in SDK 3.1 (at least in the simulator, so I would guess on device too)