The docs for SDL_LoadWAV (and SDL_LoadWAV_RW) describe the spec parameter as “an SDL_AudioSpec structure representing the desired output format”, implying that it’s an input parameter. In fact, as I understand it, it’s an output parameter in which is returned the format of the loaded WAV file (the same as the returned value) and does not need to be initialised.
This error caused me considerable confusion and led me to write code which was significantly more complicated than it needed to be. Please correct it.