[SDL] No Sound Output

John Popplewell john at johnnypops.demon.co.uk
Wed Nov 2 19:04:06 PST 2005


On Wed, Nov 02, 2005 at 05:38:32PM -0500, Timm Murray wrote:
> On Wednesday 02 November 2005 01:20 pm, Bill Kendrick wrote:
> > On Wed, Nov 02, 2005 at 11:32:14AM -0500, Timm Murray wrote:
> > > I'm on Gentoo.  I emerged SDL_mixer again, but it still segfaults.
> >
> > What does your code look like now?  Before, you had:
> >
> >  printf( "Playing file: %s\n", file );
> >  wav = Mix_LoadWAV( file );
> >  ret = Mix_PlayChannel( -1, wav, -1 );
> >  if( 0 > ret ) {
> >   printf( "Error playing audio: %s\n", Mix_GetError() );
> 
> ----
>         printf( "Playing file: %s\n", file );
>         wav = Mix_LoadWAV( file );
>         if(! wav) {
>                 printf( "Can't load wav file: %s\n", Mix_GetError() );
>                 exit(1);
>         }
>         
>         ret = Mix_PlayChannel( -1, wav, -1 );
>         if( 0 > ret ) { 
>                 printf( "Error playing audio: %s\n", Mix_GetError() );
>         }
>         else {
>                 printf( "Played on channel %i\n", ret );
>         }
>         while(Mix_Playing(-1) > 0);
> ----
> 
> Compiled with: gcc `sdl-config --libs --cflags` -lSDL_mixer -o play_sound 
> play_sound_mixer.c
> 
> Gives:
> 
> ----
> $ ./play_sound ../data/sound/plasma.wav  
> Playing file: ../data/sound/plasma.wav
> Played on channel 0
> Fatal signal: Segmentation Fault (SDL Parachute Deployed)
> ----
> 
> The 'wavplay' program on my system plays the sound successfully.
Hi,

I'm on Gentoo. Your program builds and works here. It doesn't handle
bad/missing file paths well, but it does play. I'd recommend checking the
return value from SDL_Init(). Something like this:

    ret = SDL_Init(SDL_INIT_AUDIO);
    if ( 0 > ret ) {
        printf("Error initialising SDL: %s\n", SDL_GetError());
        exit(1);
    }

What do you get if you do:

ldd ./play_sound
  linux-gate.so.1 =>  (0xffffe000)
  libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0xb7f69000)
  libpthread.so.0 => /lib/libpthread.so.0 (0xb7f31000)
  libSDL_mixer-1.2.so.0 => /usr/lib/libSDL_mixer-1.2.so.0 (0xb7ece000)
  libc.so.6 => /lib/libc.so.6 (0xb7d9d000)
  libstdc++.so.5 => //usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5 (0xb7ce3000)
  libm.so.6 => /lib/libm.so.6 (0xb7cbe000)
  libdl.so.2 => /lib/libdl.so.2 (0xb7cb9000)
  libX11.so.6 => /usr/lib/libX11.so.6 (0xb7bed000)
  libXext.so.6 => /usr/lib/libXext.so.6 (0xb7bdf000)
  libvga.so.1 => /usr/lib/libvga.so.1 (0xb7b71000)
  libaa.so.1 => /usr/lib/libaa.so.1 (0xb7b56000)
  /lib/ld-linux.so.2 (0xb7fe9000)
  libvorbisfile.so.3 => /usr/lib/libvorbisfile.so.3 (0xb7b4f000)
  libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0xb7b26000)
  libogg.so.0 => /usr/lib/libogg.so.0 (0xb7b21000)
  libsmpeg-0.4.so.0 => /usr/lib/libsmpeg-0.4.so.0 (0xb7ac9000)
  libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libgcc_s.so.1 (0xb7ac1000)
  libslang.so.1 => /usr/lib/libslang.so.1 (0xb7a4d000)

What about if you do ldd on the fullpath to libSDL_mixer? I get:

ldd /usr/lib/libSDL_mixer-1.2.so.0
  linux-gate.so.1 =>  (0xffffe000)
  libvorbisfile.so.3 => /usr/lib/libvorbisfile.so.3 (0xb7f96000)
  libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0xb7f6d000)
  libogg.so.0 => /usr/lib/libogg.so.0 (0xb7f68000)
  libsmpeg-0.4.so.0 => /usr/lib/libsmpeg-0.4.so.0 (0xb7f10000)
  libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0xb7e90000)
  libpthread.so.0 => /lib/libpthread.so.0 (0xb7e59000)
  libc.so.6 => /lib/libc.so.6 (0xb7d28000)
  libm.so.6 => /lib/libm.so.6 (0xb7d02000)
  libstdc++.so.5 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5 (0xb7c48000)
  libdl.so.2 => /lib/libdl.so.2 (0xb7c44000)
  libX11.so.6 => /usr/lib/libX11.so.6 (0xb7b78000)
  libXext.so.6 => /usr/lib/libXext.so.6 (0xb7b6a000)
  libvga.so.1 => /usr/lib/libvga.so.1 (0xb7afb000)
  libaa.so.1 => /usr/lib/libaa.so.1 (0xb7ae0000)
  /lib/ld-linux.so.2 (0x80000000)
  libgcc_s.so.1 => /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libgcc_s.so.1 (0xb7ad8000)
  libslang.so.1 => /usr/lib/libslang.so.1 (0xb7a64000)

I had a problem with SDL_Mixer and using an external libmikmod (the default on
Gentoo). It kept trying to create files ('music.raw'?) on the hardrive, and if
it couldn't then SDL audio initialisation failed. I manually rebuilt SDL_mixer
whilst disabling use of an external libmikmod.

Hope that helps,

cheers,
John.

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





More information about the SDL mailing list