LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   SDL, suddenly music functionality stopped working! (https://www.linuxquestions.org/questions/programming-9/sdl-suddenly-music-functionality-stopped-working-880767/)

malloc 05-14-2011 07:16 PM

SDL, suddenly music functionality stopped working!
 
The problem started with that I got a lot of errors about missing header files included from SDL_mixer.h when I attempted to compile my projects.
I looked in the directory of this file, and all header files were missing except SDL_mixer.h

Resolved this by compiling and installing the base SDL library package.

Programs that got recompiled and were able to play music before suddenly produced no music, but sound effects worked. However, old binaries that were compiled prior to the issue with the missing header files played music fine.

What the heck is this? I get no errors, nor warnings; none at compilation, none on execution. The kernel pool (dmesg) is clean.

There is also another strange issue, which perhaps has nothing to do with the first issue.

x86_1$ ./fire
XDM authorization key matches an existing client!Couldn't initialize SDL: Couldn't open X11 display

This might be related to a bug in XDM from searching on Google.

SigTerm 05-15-2011 03:31 AM

Quote:

Originally Posted by malloc (Post 4356553)
play music

Which format(*.ogg, *.mp3, *.wav, *.mod?) and using which function?

Quote:

Originally Posted by malloc (Post 4356553)
The problem started with that I got a lot of errors about missing header files included from SDL_mixer.h when I attempted to compile my projects.

I suspect that you disabled/compiled out support for music format(s) you wanted.
If I remember correctly, by default sdl_mixer can play only wav/voc files and support for everything else is optional. Support for ogg and mp3 files is optional and can be disabled, midi requires either timidity daemon (many modern sound cards don't support midi) or enabling timidity support within sdl_mixer, same applies to mod files.
Check SDL_mixer documentation, and check for error messages.

malloc 05-15-2011 11:36 AM

Quote:

Originally Posted by SigTerm (Post 4356736)
Which format(*.ogg, *.mp3, *.wav, *.mod?) and using which function?


I suspect that you disabled/compiled out support for music format(s) you wanted.
If I remember correctly, by default sdl_mixer can play only wav/voc files and support for everything else is optional. Support for ogg and mp3 files is optional and can be disabled, midi requires either timidity daemon (many modern sound cards don't support midi) or enabling timidity support within sdl_mixer, same applies to mod files.
Check SDL_mixer documentation, and check for error messages.

I'm using XM (Fasttracker II) but it also fails with OGG -- both of which worked fine previously.

This is what I'm doing:

Code:

if(Mix_OpenAudio(11025, AUDIO_U8, 2, 512) < 0) {
        fprintf(stderr, "Warning: Unable to initialize audio: %s\n", SDL_GetError());
                return 1;
}

music = Mix_LoadMUS(LEVEL0_MUSIC);

Mix_PlayMusic(music, -1);

I got this from an example program that I found somewhere in an SDL guide. The example program itself also fails to work.

SigTerm 05-15-2011 12:53 PM

Quote:

Originally Posted by malloc (Post 4356989)
I'm using XM (Fasttracker II) but it also fails with OGG -- both of which worked fine previously.

Then you either uninstalled libogg or compiled sdl_mixer without ogg support.

Quote:

Originally Posted by malloc (Post 4356989)
Code:

music = Mix_LoadMUS(LEVEL0_MUSIC);

Mix_PlayMusic(music, -1);


You aren't checking if your program could load the music. If it isn't playing, then it is probably NULL. I already gave you a link to the documentation in previous post.

Quote:

Originally Posted by malloc (Post 4356989)
The example program itself also fails to work.

In the future, instead of saying it "fails to work", explain HOW it fails to work, because it IS important. Program may fail to launch because of missing library. It may crash. It may launch without doing anything, and so on.

malloc 05-15-2011 06:14 PM

Quote:

Originally Posted by SigTerm (Post 4357069)
Then you either uninstalled libogg or compiled sdl_mixer without ogg support.


You aren't checking if your program could load the music. If it isn't playing, then it is probably NULL. I already gave you a link to the documentation in previous post.


In the future, instead of saying it "fails to work", explain HOW it fails to work, because it IS important. Program may fail to launch because of missing library. It may crash. It may launch without doing anything, and so on.

Sorry about that, but I implied that it fails in just the same manner as what I wrote in the original post, "I get no errors, nor warnings; none at compilation, none on execution. The kernel pool (dmesg) is clean.". So the program works fine, except that there is no music.

Rather silly of me to omit handling the return value, I get -- like you suggested -- "Mix_LoadMUS() failed on loading ./data/title.xm: Unrecognized music format".

I have recompiled and installed:

SDL-1.2.14.tar.gz
SDL_gfx-2.0.20.tar.gz
SDL_mixer-1.2.11.tar.gz

But it doesn't seem to help.

SigTerm 05-15-2011 06:24 PM

Quote:

Originally Posted by malloc (Post 4357297)
I have recompiled and installed:

./configure script normally supports several optional flags can enable/disable certain functionality. To get list of flags, launch "./configre --help". Make sure that mod files support is enabled.

Quote:

Originally Posted by malloc (Post 4357297)
Rather silly of me to omit handling the return value, I get -- like you suggested -- "Mix_LoadMUS() failed on loading ./data/title.xm: Unrecognized music format".

There are three possible scenarios: either SDL_mixer requires libmikmod (and it is not installed) in order to play files, or mod file support should be enabled (during compilation) using ./configure script, or or xm file format is unsupported.

malloc 05-25-2011 03:35 PM

Now that I've finally gotten around to deal with this issue -- I guess I'll never know why it suddenly stopped working in the first place -- by recompiling and installing libmikmod and then recompiling and installing sdlmixer I'm only facing a new issue:

I get the following error when I attempt to execute my project which was previously working fine:

"XDM authorization key matches an existing client!Error: Unable to init SDL: Couldn't open X11 display"

I also get the same error when I try to execute a lot of other programs, many of them not my own. It seems that the error is not caused by using SDL_Mixer either, as some pure graphics demos without any audio functionality also give me this message, and when I removed all audio features from my program to try to isolate the issue it still gave that error upon execution.


All times are GMT -5. The time now is 12:10 PM.