Jump to content
  • Advertisement
Sign in to follow this  
ukdeveloper

Problems with audio on custom SDL framework

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've been working on a custom SDL framework since yesterday. It's not finished, but it'll be an Object Oriented solution to creating simple games in SDL, expandable as I need it. Problem is, the audio functions have gone horribly, horribly wrong, and I can't see exactly why. I've uploaded the source here (I know it says TicTacToe, that's the first game I'm developing using my framework - it's basically a testing system). The error handling was put in just so I could see it was all working correctly. ttt.cpp has the main() function, and you'll be able to see wmanager.h/.cpp, spritewrapper.h/.cpp, and audiowrapper.h/.cpp - these are the framework components. Please allow me to say again that it isn't finished - there is some stuff missing. Now, here's the slightly odd bit. In main, if I comment out all the Audio. functions, except
Audio.InitAudio();
, the window opens as normal and hangs. It never reaches
return 0;
If I comment out
Audio.InitAudio();
, and leave the other Audio function calls uncommented, the error handler pops up saying abc.wav doesn't exist, even when it does. And then the next error handler pops up saying that the sound couldn't be played because it was trying to play a NULL chunk. If I comment out
Audio.PlayAudio();
(with its associated parameters), and leave
Audio.InitAudio();
and
Audio.LoadAudio();
and
Audio.FreeAudioChunk();
(both with their associated parameters) uncommented, again the window opens as normal and hangs without reaching
return 0;
Finally, if I leave it all uncommented, the window opens as normal. The error handler says that playing the sound file failed, the next error box pops up saying that it tried to play a NULL chunk, and then the program exits absolutely normally. In this case, no errors appear to suggest the initial loading of the sound file from /data/ into the chunk failed. The sprite seems to be loading fine without any kind of errors, but I'm not testing blitting it just yet. I really do apologise for the length of my post, but this is a weird problem, I've never seen anything like it at all. It only affects the audio functions - commenting out all of them causes the program to open and close normally. There isn't even any segfaulting going on either. I hope my code is clear enough for you to investigate, should you be interested. Any problems, please let me know. Hope you can help, thanks in advance for your time and help, ukdeveloper.

Share this post


Link to post
Share on other sites
Advertisement
Too bad. I wanted to compile the program but it complains about a syntax error in SDL_audio.h!?
Weird ...

The one thing that looks weird to me is that you pass a Mix_Chunk pointer called sound in LoadAudio and PlayAudio.

There is also a public variable with the same name.
Maybe the wrong one is set and the correct one is NULL?
Probably I just didn't quite understand what you are doing, though.
Might not be an error at all.

Why don't you work with constructors and destructors btw.?
You should always give the member variables standard values like NULL for pointers.
Some weird errors can be avoided that way.

Share this post


Link to post
Share on other sites
Quote:
Original post by Clueless
Why don't you work with constructors and destructors btw.?


As it happens, I rewrote it all using that method and all's well now.

Thanks for going to the trouble of testing it anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!