Kudos to getting to this point. Adding support for more mappers is a nice incremental thing that can be done at your leisure, and once you get save states implemented, playing games at your own pace is super fun :)
Thanks! Mapper 1 is since done as well as battery-backed RAM support, and I'll be implementing mappers 2-4 in the next couple days. I just read your blog post and the audio section caught my eye: I went through the exact same struggles with trying to queue 44,100Hz to SDL, including trying to implement dynamic sampling, but it was never quite right and I got quite frustrated with it. So eventually I took another pass at using the callback method instead, which I thought wasn't possible as you can't exfiltrate a reference to the struct that you give the audio device, but I got it to work this time with an Arc<Mutex<Vec<u8>>> and it's wayyy better.
The APU sends all of its samples to a staging buffer, then between video frames, the Mutex for the SDL buffer is locked and the staging buffer is emptied into it. The SDL callback also locks the Mutex 60 times per second, takes evenly spaced samples from the raw data, and truncates what it consumed if it had more than it needed. Now the audio keeps perfect pace with the emulator, whether it slows to 58 FPS or goes too fast, and there's no popping and clicking. If you're curious, here are the relevant spots in the code now:
Kudos to getting to this point. Adding support for more mappers is a nice incremental thing that can be done at your leisure, and once you get save states implemented, playing games at your own pace is super fun :)