LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-14-2011, 08:16 PM   #1
malloc
Member
 
Registered: Jul 2010
Posts: 111

Rep: Reputation: 4
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.
 
Old 05-15-2011, 04:31 AM   #2
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by malloc View Post
play music
Which format(*.ogg, *.mp3, *.wav, *.mod?) and using which function?

Quote:
Originally Posted by malloc View Post
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.
 
Old 05-15-2011, 12:36 PM   #3
malloc
Member
 
Registered: Jul 2010
Posts: 111

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by SigTerm View Post
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.
 
Old 05-15-2011, 01:53 PM   #4
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by malloc View Post
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 View Post
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 View Post
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.
 
Old 05-15-2011, 07:14 PM   #5
malloc
Member
 
Registered: Jul 2010
Posts: 111

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by SigTerm View Post
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.
 
Old 05-15-2011, 07:24 PM   #6
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by malloc View Post
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 View Post
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.
 
Old 05-25-2011, 04:35 PM   #7
malloc
Member
 
Registered: Jul 2010
Posts: 111

Original Poster
Rep: Reputation: 4
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ALSA suddenly stopped working. Optimistic Debian 14 05-23-2008 12:04 PM
vmware suddenly stopped working leupi Linux - Software 7 01-22-2007 09:47 PM
apache suddenly stopped working newlinuxnewbie Linux - General 21 11-25-2005 04:56 PM
Sound has stopped working suddenly mrmuckle Linux - General 2 10-15-2005 02:57 PM
crontab suddenly stopped working corepuncher Linux - General 4 02-18-2005 06:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration