hi.
when playing sound using sdl mixer it seems like there is a delay with playing the sound and id doesn’t happen instantly, specially on android device, is there a way to fix it?
Audio::Audio()
{
intance = this;
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0)
{
printf("SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError());
}
Mix_AllocateChannels(32);
}
void Audio::PlaySound(std::string key)
{
int chnl = Mix_PlayChannel(-1, sounds[key], 0);
}
void Audio::LoadSound(std::string path)
{
sounds[path] = nullptr;
Mix_Chunk* sound = Mix_LoadWAV(path.c_str());
if (sound == NULL)
{
printf("Failed to load sound SDL_mixer Error: %s\n", Mix_GetError());
}
else
{
sounds[path] = sound;
}
}