Since updating to SDK 2.7.1, Poker Poker Magic version 1.6.0 crashes on device and in the simulator. In the simulator, it crashes with the following message:
com.apple.audio.IOThread.client (22)
Assertion failed: (bytes <= RingBuffer_getBytesAvailable(r)), function RingBuffer_moveOutputPointer, file ringbuffer.c, line 183.
It happens when I call playdate->sound->fileplayer->stop
in the callback from playdate->sound->fileplayer->fadeVolume
. If I remove the call to stop
, it does not crash.
static void stopFilePlayer(SoundSource * _Nonnull source, void * _Nullable userdata);
void MusicManagerPlay(const char * _Nonnull music, int repeat, float crossFadeDuration) {
const struct playdate_sound_fileplayer *filePlayerAPI = playdate->sound->fileplayer;
/* ... */
const int32_t duration = kFrequency * crossFadeDuration;
filePlayerAPI->fadeVolume(currentPlayer, 0.0f, 0.0f, duration, stopFilePlayer, NULL);
/* ... */
}
static void stopFilePlayer(SoundSource * _Nonnull source, void * _Nullable userdata) {
FilePlayer *self = (FilePlayer *)source;
// Crash here. Does not crash if the next line is removed.
playdate->sound->fileplayer->stop(self);
}