SDL_mixer is failing when sequentially playing same sound under 20 ms intervals

Hello. I’ve been trying to solve this by my own for days, but can’t find any solution.

When I play the same Mix_Chunk* repeteadly, with a very short interval between these (< 20ms), the audio intermitently fails/delays. I’ve create an isolated main.c just to see if it could be any problem with updates taking too long on each frame (although graphics runs smoothly on 60 FPS), but the problem is still exaclty the same. I tried different chunk sizes, but below 1024 it gets distorted, and above 2048 there is a noticeable delay. Problem is the same with anything between.

Below is the code that I used. I can’t upload the .MP3 that it plays because I’m a new user, but it was an edited version of this, to play one shot only. Help me, SDL Forums. You’re my only hope.

#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <string>
#include <stdexcept>
#include <iostream>


int main() {

if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) != 0 ) {
	std::string message("Error Initializing SDL2. Cause:");
	message += SDL_GetError();

	throw std::runtime_error( message );
}

if ( Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 ) {
	printf( Mix_GetError() );
	
	abort();
}


const char* mp3 = "M1 Garand Gun-SoundBible.com-1519788442.mp3";
Mix_Chunk* chunk = Mix_LoadWAV( mp3 );

Mix_AllocateChannels( 128 );
Mix_Volume(-1, MIX_MAX_VOLUME / 10);

SDL_Window* window = SDL_CreateWindow("sound demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
	400, 200, SDL_WINDOW_SHOWN);

bool quit = false;

SDL_Event e;

while (!quit) {
	while ( SDL_PollEvent( &e ) != 0 ) {
		if ( e.type == SDL_QUIT ) {
			quit = true;
		}
	}
	
	auto keyboardState = SDL_GetKeyboardState( nullptr );
	
	if ( keyboardState[ SDL_SCANCODE_RETURN ] ) {
		Mix_PlayChannel( -1, chunk, 0 );
		SDL_Delay(100);
		
                    //It starts to print the same number(6) here
		printf("%d\n", Mix_Playing(-1));
	}
}

return 0;	

}