Sound segmentation fault

All this past week I’ve been trying to find a way to initialize sound under SDL. Trouble here is that SDL does not provide a way, at least not by default, to query the current machine for an audio device prior to initializing sound. Has anyone found ways to initialize sound without having sdl core dump at exit, when no audio device is available. I’ve searched the web, combed SDL_docs, and even gone through the SDL/src/audio/* files without much luck. The only function that could be useful in this task is SDL_OpenAudioPath, but that function does not seem to be available through sdl.

Anyone had such problem, or have a ( multi-platform )suggestion on how to query a machine for an audio deice. I’m really lost here and would really appreciate any response.

Thanks in advance,–
Juan

All this past week I’ve been trying to find a way to initialize sound
under SDL. Trouble here is that SDL does not provide a way, at least
not by default, to query the current machine for an audio device prior
to initializing sound. Has anyone found ways to initialize sound
without having sdl core dump at exit, when no audio device is
available. I’ve searched the web, combed SDL_docs, and even gone
through the SDL/src/audio/* files without much luck. The only function
that could be useful in this task is SDL_OpenAudioPath, but that
function does not seem to be available through sdl.

What platform? Windows? Linux?

What you’re describing would be a bug in SDL, not something that you
should have to work around with different function calls.

–ryan.

What platform? Windows? Linux?

What you’re describing would be a bug in SDL, not something that you
should have to work around with different function calls.------------------------------

Thanks for the response. The platform is FreeBSD 5.1-CURRENT.
Linking against SDL-1.2.6, gcc 3.2.2, with ‘device pcm’ compiled ( in
the odd case I ever get an audio card ). I know that it’s not just
my program that has this problem, other programs that utilize sdl
segfault as well ( IEL: mplayer, zsnes, dgen ). Only program that did
not segfault at exit was the Railroad Tycoon 2 demo that I installed
from ports. Perhaps some of your ex-loki buddies can shed some light on how they got around this problem.

Thanks again,


Juan

Thanks for the response. The platform is FreeBSD 5.1-CURRENT.
Linking against SDL-1.2.6, gcc 3.2.2, with ‘device pcm’ compiled ( in
the odd case I ever get an audio card ). I know that it’s not just
my program that has this problem, other programs that utilize sdl
segfault as well ( IEL: mplayer, zsnes, dgen ). Only program that did
not segfault at exit was the Railroad Tycoon 2 demo that I installed
from ports. Perhaps some of your ex-loki buddies can shed some light on how they got around this problem.

Have you been able to debug the problem and see where SDL is crashing?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

segfault as well ( IEL: mplayer, zsnes, dgen ). Only program that did
not segfault at exit was the Railroad Tycoon 2 demo that I installed
from ports. Perhaps some of your ex-loki buddies can shed some light
on how they got around this problem.

Likely it’s something that broke since RT2 shipped (it uses it’s own
build of SDL, not the system-wide one, at least by default).

What we need now is a backtrace of an SDL program crashing on your
system. Can you run one under gdb and send the information on to the
list?

If you’ve never done this before, here’re some brief instructions. If
"./crashingprogram" is a SDL-based app experiencing this bug:

  • Run “gdb ./crashingprogram”
  • At the gdb prompt, hit “r”.
  • Crash the program. You will want to make sure that the mouse cursor
    was not grabbed by the app at the time it crashes, or it’ll freeze
    your X server.
  • Assuming your system isn’t frozen :), enter “bt” at the gdb prompt.
  • Send us the data it spits out.

Thanks,
–ryan.

What we need now is a backtrace of an SDL program crashing
on your system. Can you run one under gdb and send the information on to the list?===============================

Compiled with 'g++ sdl-config --cflags -ggdb x.cc -o x sdl-config --cflags -lSDL_mixer, and went to bt here’s what gdb spat out:

#0 0x288cce50 in ?? ()
#1 0x0804887d in _start ()

Didn’t look too informative so I decided to step through the program and had it segfault at SDL_Init() with the following:

Program received signal SIGSEGV, Segmentation fault.
0x2822f334 in _longjmp () from /usr/lib/libc.so.5

Am really lost on this one :-/, I’ll attach my test code don’t think I’ve made any mistakes but just in case I have here is my code.

#include “SDL.h”
#include “SDL_mixer.h”

#include
using namespace std;

int main( int argc, char* argv[] )
{
const int Rate = 44000;
const int Channels = 2;
const int Buff = 4096;
const Uint16 Format = AUDIO_S16;

if( SDL_Init( SDL_INIT_VIDEO|SDL_INIT_AUDIO ) ){
	cerr<<"Unable to initialize SDL: "<<SDL_GetError()<<'.'<<endl;
	exit( 1 );
}
atexit( SDL_Quit );

SDL_Surface* screen = SDL_SetVideoMode( 200,  200, 0, SDL_ANYFORMAT );

if( !SDL_InitSubSystem( SDL_INIT_AUDIO ) ){
	if( Mix_OpenAudio( Rate, Format, Channels, Buff ) ){
		std::cerr<<"Unable to initialize audio device: "<<SDL_GetError()<<'.'<<std::endl;
	}
}

}

I apprecieate the help so far, and hope someone will be able to
help me fix this problem.

Thanks again,


JUan

Hrrmm, this sounds errily similar to a problem I was having when using
VC++7. Try passing the SDL_INIT_NOPARACHUTE flag to your SDL_Init() call –
thats how I “fixed” it in VC++7 (Actually, I’ve found several different
"bugs" that are somehow fixed by disabling the parachute; so much so that
it’s now in every SDL app I write – perhaps there’s a bug in the VC++ code
for the parachute?).

  • Silicon> ----- Original Message -----

From: socomm@myrealbox.com (Juan D. Espinoza)
To:
Sent: Thursday, December 18, 2003 4:27 PM
Subject: Re: Re: Re: [SDL] Sound segmentation fault.

What we need now is a backtrace of an SDL program crashing
on your system. Can you run one under gdb and send the information on to the
list?

===============================

Compiled with 'g++ sdl-config --cflags -ggdb x.cc -o x
sdl-config --cflags -lSDL_mixer, and went to bt here’s what gdb spat out:

#0 0x288cce50 in ?? ()
#1 0x0804887d in _start ()

Didn’t look too informative so I decided to step through the program and had
it segfault at SDL_Init() with the following:

Program received signal SIGSEGV, Segmentation fault.
0x2822f334 in _longjmp () from /usr/lib/libc.so.5

Am really lost on this one :-/, I’ll attach my test code don’t think I’ve
made any mistakes but just in case I have here is my code.

#include “SDL.h”
#include “SDL_mixer.h”

#include
using namespace std;

int main( int argc, char* argv[] )
{
const int Rate = 44000;
const int Channels = 2;
const int Buff = 4096;
const Uint16 Format = AUDIO_S16;

if( SDL_Init( SDL_INIT_VIDEO|SDL_INIT_AUDIO ) ){
cerr<<"Unable to initialize SDL: "<<SDL_GetError()<<’.’<<endl;
exit( 1 );
}
atexit( SDL_Quit );

SDL_Surface* screen = SDL_SetVideoMode( 200, 200, 0, SDL_ANYFORMAT );

if( !SDL_InitSubSystem( SDL_INIT_AUDIO ) ){
if( Mix_OpenAudio( Rate, Format, Channels, Buff ) ){
std::cerr<<“Unable to initialize audio device:
”<<SDL_GetError()<<’.’<<std::endl;
}
}

}

I apprecieate the help so far, and hope someone will be able to
help me fix this problem.

Thanks again,


JUan


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.552 / Virus Database: 344 - Release Date: 12/15/2003