Problem with SDL_Mixer

Hey all,

These few lines:

if(Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024) == -1)

{

    printf("Warning: Couldn't set 44100 Hz 16-bit audio\n - Reason:

%s\n", SDL_GetError());

} 

.Are causing my SDL app to freeze due to a segmentation fault. I realized it
was these lines due to the fact that when I comment them out, the program
runs smoothly. I don’t see why they’re causing me a problem, because I’ve
implemented SDL_Mixer successfully before and never had these problems. The
only change in this program is that they’re now in an SDL_init() function,
which is called by main, rather than actually being in main.

I’m including the following SDL headers:

#include <SDL/SDL.h>

#include <SDL_mixer.h>

#include <SDL_opengl.h>

#include “TTF\SDL_ttf.h”

.And linking to:

“…/…/OpenGL .lib and .h/libglu32.a”

-lmingw32

-lSDLmain

-lSDL

-lopengl32

SDL_ttf.dll

-lSDL_mixer

With the compiler option:

-Dmain=SDL_main

Many thanks for your help in advance!

  • Sputty

Wednesday 18 of June 2008 16:04:19 Ben Ockmore napisa?(a):

Hey all,

These few lines:

if(Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024) == -1)

{

    printf("Warning: Couldn't set 44100 Hz 16-bit audio\n - Reason:

%s\n", SDL_GetError());

}

.Are causing my SDL app to freeze due to a segmentation fault. I realized
it was these lines due to the fact that when I comment them out, the
program runs smoothly. I don’t see why they’re causing me a problem,
because I’ve implemented SDL_Mixer successfully before and never had these
problems. The only change in this program is that they’re now in an
SDL_init() function, which is called by main, rather than actually being in
main.

I’m including the following SDL headers:

#include <SDL/SDL.h>

#include <SDL_mixer.h>

#include <SDL_opengl.h>

#include “TTF\SDL_ttf.h”

.And linking to:

“…/…/OpenGL .lib and .h/libglu32.a”

-lmingw32

-lSDLmain

-lSDL

-lopengl32

SDL_ttf.dll

-lSDL_mixer

With the compiler option:

-Dmain=SDL_main

Many thanks for your help in advance!

  • Sputty

The problem can be with the ‘printf’ function: add to linker
flags -mwindows -mconsole at the end. In my programs linking without this
flags causes seg fault when I use ‘cout’.–
Regards,
Dominik Dagiel

Hmm, thanks for the suggestion, but that doesn’t solve the problem - It just
brings up the console window. SDL is handling the printf()s, so the output
goes to stdout.txt instead.

When I commented out printf(), it still didn’t work, so I’m pretty sure that
the problem is with the Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024)…

Any suggestions?

Many thanks,

-Sputty> ----- Original Message -----

Date: Wed, 18 Jun 2008 18:26:56 +0000
From: dominik@dagiel.pl (Dominik Dagiel)
Subject: Re: [SDL] Problem with SDL_Mixer
To: “A list for developers using the SDL library. (includes
SDL-announce)”
Message-ID: <200806181826.56141.dominik at dagiel.pl>
Content-Type: text/plain; charset=“utf-8”

Wednesday 18 of June 2008 16:04:19 Ben Ockmore napisa?(a):

Hey all,

These few lines:

if(Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024) == -1)

{

    printf("Warning: Couldn't set 44100 Hz 16-bit audio\n - Reason:

%s\n", SDL_GetError());

}

.Are causing my SDL app to freeze due to a segmentation fault. I realized
it was these lines due to the fact that when I comment them out, the
program runs smoothly. I don’t see why they’re causing me a problem,
because I’ve implemented SDL_Mixer successfully before and never had these
problems. The only change in this program is that they’re now in an
SDL_init() function, which is called by main, rather than actually being
in
main.

I’m including the following SDL headers:

#include <SDL/SDL.h>

#include <SDL_mixer.h>

#include <SDL_opengl.h>

#include “TTF\SDL_ttf.h”

.And linking to:

“…/…/OpenGL .lib and .h/libglu32.a”

-lmingw32

-lSDLmain

-lSDL

-lopengl32

SDL_ttf.dll

-lSDL_mixer

With the compiler option:

-Dmain=SDL_main

Many thanks for your help in advance!

  • Sputty

The problem can be with the ‘printf’ function: add to linker
flags -mwindows -mconsole at the end. In my programs linking without this
flags causes seg fault when I use ‘cout’.


Regards,
Dominik Dagiel

Hello !

When I commented out printf(), it still didn’t work, so I’m pretty sure that
the problem is with the Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024)…

Any suggestions?

We need more information. Do you use SDL_Init
(SDL_INIT_VIDEO|SDL_INIT_AUDIO) ?

Please compile and test the example app that comes with SDL_mixer.
Try your soundfiles there and see if then SDL_mixer also crashes.

CU