Hello folks!
I’m developing a simple game as a start point to learn the SDL library
and its add-ons.
Specially at SDL_Mixer, I noticed a strange behaviour.
If I wait more than a specific amount of time (in the order from
miliseconds to seconds) after Mix_OpenAudio, to call Mix_PlayChannel,
the sound (a Mix_Chunk* variable) doesn’t play!
I tried it on my game, and on the playwave.c example bounded with
SDL_Mixer. The problem happened in both cases.
So, here are my questions: Do I have to be quick to play my "chunk"
after a call to Mix_OpenAudio? If yes, how quick should I be?
If no, is this a bug? If so, what can I do?
Below is a code snap of the test:
/------------------------------------------------------------------------/
int AudioRate = 22050, AudioChannels = 2;
Uint16 AudioFormat = AUDIO_S16;
int ChannelOfSound;
Mix_Chunk *Sound;
if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT,
MIX_DEFAULT_CHANNELS, 8192) < 0)
fprintf(stderr, “Error on Mix_OpenAudio: %s\n”, SDL_GetError());
/*** << Here is the point! >> ***/
/* Small values, it works fine */
/* Great values, doesn't work... */
SDL_Delay(1280);
printf("Playng now...\n");
Sound = Mix_LoadWAV("./sons/pop.wav");
if(Sound == NULL)
fprintf(stderr, "Error on loading pop.wav: %s\n", SDL_GetError());
ChannelOfSound = Mix_PlayChannel(-1, Sound, 0);
SDL_Delay(191); // it must be at least 191!?
if(Sound != NULL)
Mix_FreeChunk(Sound);
Mix_CloseAudio();
/------------------------------------------------------------------------/
Thanks for the attention!–
Adriano Del Vigna de Almeida
JIT JC
@Adriano_Del_Vigna_de
ICQ #:14898488
Curitiba - Brasil