Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL_OpenAudio() conundrum =/

Started by NicolasJay Jan 4, 2011 at 12:51 PM 1 replies 1.8k views
Original Post
NicolasJay
NicolasJay
Hello!

I am trying to finish up a school project using SDL 1.2, but I have hit a snag that I can't get by.

The game has several game state modules, each with a function
int Run(SDL_Surface *screen);

In each module, Run() initializes audio, runs through its loop, then closes audio before returning.

all of the modules use Mix_OpenAudio() and Mix_CloseAudio() to init/deinit the sound, and work fine together.

The only exception is the cinematic movie module where I have used SDL_FFMpeg to show a movie. This module forces me to use SDL_OpenAudio() instead.

SDL_OpenAudio fails the first time with the error "Audio device is already open", but then works the second time.

Once I have run the movie module, all the sound in the other modules stops working even though all their functions return 0 for success.

anyone have any idea whats going on? I am lost on this one =/

thanks for any help,
Nick
NicolasJay
NicolasJay
I actually found the answer to this in one simple formula.

SDL 1.2 = fail.
nfries88
nfries88
Are you certain that SDL_CloseAudio is always performed at the end? That may cause issues. See:


audio = current_audio;
if (audio->opened) {
SDL_SetError("Audio device is already opened");
return(-1);
}


Basically a check to see if audio is already opened or not. Meaning that it was not closed if you're getting this error. May be an error in SDL_mixer; but more than likely it's something you're doing wrong.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.