Noob questions about SDL2 Audio API and artifacts

I’ve got two questions. First: is the pull API designed for doing the actual audio processing in the callback(as opposed to just copying from a buffer)? I guess what I want to know is whether it would be redundant to pull from a circular buffer that’s filled up by another thread.

Second question: I had these pops and crackles that I couldn’t get rid of when testing with a simple square wave that I generate in code. I tried different formats and buffer sizes but to no avail. Then I upgraded from 2.0.12 to 2.0.14 and now the artifacts are gone. I looked at the changelog and skimmed the issues pages but couldn’t find anything about it. So for my sanity (because nothing makes me more nervous than when things magically starts working) I’m wondering if any bugs that could have caused the artifacts were fixed between the two versions?

In a perfect world, very little processing should happen in the callback, but often times, fairly complex code runs in there (for example, SDL_mixer and MojoAL both do all their mixing and spatial processing work in the callback function).

As long as the callback finishes in time for SDL to hand the final buffer to the hardware, it’s fine.

Probably, but it’s worth saying that if you just want to make a circular buffer, you might as well use SDL_QueueAudio() and let SDL handle it. You just supply more audio data to the queue at your leisure from whatever thread in this case.

It could be lots of things. :woman_shrugging:

1 Like

I suspected that might be the case. thanks for answering my questions!