Problems with SDL_mixer

hi,

I’m trying to use SDL_mixer with SDL 1.3, and i’m having very strange problems.

it seems that sometimes, i got no sound, while all data is good and averything
is well initiated.
It differs also from one project to another : one project works well (i got
sound 8/10 times), another has worked only ONCE.

Does anyone have the same problem?

update:

it seems that it is impossible to have sound (even with SDl not SDL_mixer) when
i activate video…

DGlobal::pState = CommonCreateState(argv, SDL_INIT_VIDEO);
CommonInit(DGlobal::pState);
SDL_SelectRenderer(DGlobal::pState->windows[0]);

http://sdl.beuc.net/sdl.wiki/SDL_Init

I assume it works the same way as SDL_Init(); haven’t really had time to play with 1.3.

Try

CommonCreateState(argv, SDL_INIT_AUDIO | SDL_INIT_VIDEO);

instead :slight_smile:

Pat> ----- Original Message -----

From: Naroin
To: sdl at libsdl.org
Sent: Wednesday, May 27, 2009 1:48:50 PM
Subject: Re: [SDL] Problems with SDL_mixer

update:

it seems that it is impossible to have sound (even with SDl not SDL_mixer) when
i activate video…

DGlobal::pState = CommonCreateState(argv, SDL_INIT_VIDEO);
CommonInit(DGlobal::pState);
SDL_SelectRenderer(DGlobal::pState->windows[0]);


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Patryk Bratkowski <pbratkowski yahoo.com> writes:

http://sdl.beuc.net/sdl.wiki/SDL_Init

I assume it works the same way as SDL_Init(); haven’t really had time to play
with 1.3.

Try

CommonCreateState(argv, SDL_INIT_AUDIO | SDL_INIT_VIDEO);

instead :slight_smile:

Pat

sorry, my post was maybe not very clear, here’s the full code:

DGlobal::pState = CommonCreateState(argv, SDL_INIT_VIDEO);
CommonInit(DGlobal::pState);
SDL_SelectRenderer(DGlobal::pState->windows[0]);

SDL_AudioInit(SDL_GetAudioDriver(0));
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 512);



Mix_Chunk* sound = Mix_LoadWAV("E:\\uploads\\sample.wav");

n = Mix_PlayChannel(-1, sound, -1);


while(1)
{
	SDL_Delay(10);
}

return 0;

as you can see, i (correctly?) init AUDIO.
Everything works well. It passes correctly in mix_channel, and the Uint* stream
is well filled with wav data. But i have no sound.

If i comment CommonInit(), it SOMETIMES works! I think directsound has some
problems with init…

I’ve also tried without SDL_mixer, but it does exactly the same. The problem
must be in a lower part, because the mix_channel function works well.

I’m very surprised i’m the only one with this problem! Maybe the problem occurs
only with VC++9 ? Or i do something very wrong? Or nobody tried sound with SDL
1.3 ? :slight_smile:

Naroin <naroin-trash altern.org> writes:

DGlobal::pState = CommonCreateState(argv, SDL_INIT_VIDEO);
CommonInit(DGlobal::pState);
SDL_SelectRenderer(DGlobal::pState->windows[0]);

SDL_AudioInit(SDL_GetAudioDriver(0));
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 512);

okaaaaayyy it’s fun.

i simply put the audio init before the video init

SDL_AudioInit(SDL_GetAudioDriver(0));
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 512);

DGlobal::pState = CommonCreateState(argv, SDL_INIT_VIDEO);
CommonInit(DGlobal::pState);
SDL_SelectRenderer(DGlobal::pState->windows[0]);

and now it works better.

But it still works about once for 3 or 4 tries. I just have to relauch the app
4 times to get sound working…
and I had to desactivate music in SDL_mixer (open_music is not called anymore)

to me, it’s nothing but magic.