Unexpected exit at first SDL_mixer call (v1.2.11 in mingw-cross-env)

Hi,

I’ve adapted my windows cross-compile build for tuxtype
(git://git.debian.org/git/tux4kids/tuxtype.git, "mingw-cross-env"
branch) to use the mingw-cross-env project. As a result, the
crossbuild now uses SDL_mixer 1.2.11 instead of a much earlier version
in my older win32 builds.

However, now tuxtype exits unexpectedly at the initial call to
Mix_OpenAudio(). Here is a snippet where the problem occurs:

if (settings.sys_sound) //NOTE - can be turned off with "–nosound"
runtime flag
{
fprintf(stderr, “-about to call Mix_OpenAudio()\n”);
if (Mix_OpenAudio(22050, AUDIO_S16, 1, 2048) == -1)
{
fprintf(stderr, “Warning: couldn’t set 22050 Hz 8-bit audio\n -
Reasons: %s\n”, SDL_GetError());
settings.sys_sound = 0;
}
else
fprintf(stderr, “Mix_OpenAudio() successful\n”);
}

The last output I get from the windows crossbuild is “-about to call
Mix_OpenAudio()\n” - it never gets to the SDL_GetError() call.

If I start tuxtype with “tuxtype --nosound” to skip this step, the
program runs fine (but silently :frowning: )

The same program works fine on Debian and Ubuntu, using SDL_mixer
1.2.8 (at least on Debian - not certain what version is in Ubuntu
karmic).

Thanks for any help,

David Bruce

Hi,

Sorry to repost this, but I haven’t heard anything after a few days -
wonder if the svn-mercurial thread occupied everyone’s attention.

Does SDL-mixer 1.2.11 work properly when cross-compiled for mingw32 on
a linux build machine, as far as everyone knows? The code within
tuxtype that uses SDL-mixer hasn’t changed for ages, and the program
works fine on linux using SDL-mixer 1.2.8.

Any suggestions?
Should I remove 1.2.11 from my mingw-cross-env setup and replace it
with SDL-mixer 1.2.8?

Thanks,

David BruceOn Fri, Feb 26, 2010 at 7:03 AM, David Bruce <@David_Bruce> wrote:

Hi,

I’ve adapted my windows cross-compile build for tuxtype
(git://git.debian.org/git/tux4kids/tuxtype.git, "mingw-cross-env"
branch) to use the mingw-cross-env project. ?As a result, the
crossbuild now uses SDL_mixer 1.2.11 instead of a much earlier version
in my older win32 builds.

However, now tuxtype exits unexpectedly at the initial call to
Mix_OpenAudio(). ?Here is a snippet where the problem occurs:

?if (settings.sys_sound) ?//NOTE - can be turned off with "–nosound"
runtime flag
?{
? ?fprintf(stderr, “-about to call Mix_OpenAudio()\n”);
? ?if (Mix_OpenAudio(22050, AUDIO_S16, 1, 2048) == -1)
? ?{
? ? ?fprintf(stderr, “Warning: couldn’t set 22050 Hz 8-bit audio\n -
Reasons: %s\n”, SDL_GetError());
? ? ?settings.sys_sound = 0;
? ?}
? ?else
? ? ?fprintf(stderr, “Mix_OpenAudio() successful\n”);
?}

The last output I get from the windows crossbuild is “-about to call
Mix_OpenAudio()\n” - it never gets to the SDL_GetError() call.

If I start tuxtype with “tuxtype --nosound” to skip this step, the
program runs fine (but silently :frowning: ?)

The same program works fine on Debian and Ubuntu, using SDL_mixer
1.2.8 (at least on Debian - not certain what version is in Ubuntu
karmic).

Thanks for any help,

David Bruce

Can you make a smaller test case?

Jonny DOn Tue, Mar 2, 2010 at 9:52 AM, David Bruce wrote:

Hi,

Sorry to repost this, but I haven’t heard anything after a few days -
wonder if the svn-mercurial thread occupied everyone’s attention.

Does SDL-mixer 1.2.11 work properly when cross-compiled for mingw32 on
a linux build machine, as far as everyone knows? The code within
tuxtype that uses SDL-mixer hasn’t changed for ages, and the program
works fine on linux using SDL-mixer 1.2.8.

Any suggestions?
Should I remove 1.2.11 from my mingw-cross-env setup and replace it
with SDL-mixer 1.2.8?

Thanks,

David Bruce

On Fri, Feb 26, 2010 at 7:03 AM, David Bruce wrote:

Hi,

I’ve adapted my windows cross-compile build for tuxtype
(git://git.debian.org/git/tux4kids/tuxtype.git, "mingw-cross-env"
branch) to use the mingw-cross-env project. As a result, the
crossbuild now uses SDL_mixer 1.2.11 instead of a much earlier version
in my older win32 builds.

However, now tuxtype exits unexpectedly at the initial call to
Mix_OpenAudio(). Here is a snippet where the problem occurs:

if (settings.sys_sound) //NOTE - can be turned off with "–nosound"
runtime flag
{
fprintf(stderr, “-about to call Mix_OpenAudio()\n”);
if (Mix_OpenAudio(22050, AUDIO_S16, 1, 2048) == -1)
{
fprintf(stderr, “Warning: couldn’t set 22050 Hz 8-bit audio\n -
Reasons: %s\n”, SDL_GetError());
settings.sys_sound = 0;
}
else
fprintf(stderr, “Mix_OpenAudio() successful\n”);
}

The last output I get from the windows crossbuild is “-about to call
Mix_OpenAudio()\n” - it never gets to the SDL_GetError() call.

If I start tuxtype with “tuxtype --nosound” to skip this step, the
program runs fine (but silently :frowning: )

The same program works fine on Debian and Ubuntu, using SDL_mixer
1.2.8 (at least on Debian - not certain what version is in Ubuntu
karmic).

Thanks for any help,

David Bruce


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi Jonny,On Tue, Mar 2, 2010 at 8:57 AM, Jonathan Dearborn wrote:

Can you make a smaller test case?

Sure - I’ll chop out about 99% of tuxtype and get back to you later today.

Thanks,

David Bruce

Hi,

Sorry to repost this, but I haven’t heard anything after a few days -
wonder if the svn-mercurial thread occupied everyone’s attention.

Does SDL-mixer 1.2.11 work properly when cross-compiled for mingw32 on
a linux build machine, as far as everyone knows? The code within
tuxtype that uses SDL-mixer hasn’t changed for ages, and the program
works fine on linux using SDL-mixer 1.2.8.

Any suggestions?
Should I remove 1.2.11 from my mingw-cross-env setup and replace it
with SDL-mixer 1.2.8?

SDL-mixer 1.2.8 did not use Mix_Init(). You should add it prior
OpenAudio for 1.2.11 usage.

Greets,

RonaldAm 02.03.2010 15:52, schrieb David Bruce:

On Fri, Feb 26, 2010 at 7:03 AM, David Bruce wrote:

Hi,

I’ve adapted my windows cross-compile build for tuxtype
(git://git.debian.org/git/tux4kids/tuxtype.git, "mingw-cross-env"
branch) to use the mingw-cross-env project. As a result, the
crossbuild now uses SDL_mixer 1.2.11 instead of a much earlier version
in my older win32 builds.

However, now tuxtype exits unexpectedly at the initial call to
Mix_OpenAudio(). Here is a snippet where the problem occurs:

if (settings.sys_sound) //NOTE - can be turned off with "–nosound"
runtime flag
{
fprintf(stderr, “-about to call Mix_OpenAudio()\n”);
if (Mix_OpenAudio(22050, AUDIO_S16, 1, 2048) == -1)
{
fprintf(stderr, “Warning: couldn’t set 22050 Hz 8-bit audio\n -
Reasons: %s\n”, SDL_GetError());
settings.sys_sound = 0;
}
else
fprintf(stderr, “Mix_OpenAudio() successful\n”);
}

The last output I get from the windows crossbuild is “-about to call
Mix_OpenAudio()\n” - it never gets to the SDL_GetError() call.

If I start tuxtype with “tuxtype --nosound” to skip this step, the
program runs fine (but silently :frowning: )

The same program works fine on Debian and Ubuntu, using SDL_mixer
1.2.8 (at least on Debian - not certain what version is in Ubuntu
karmic).

Thanks for any help,

David Bruce

Hi Ronald,

SDL-mixer 1.2.8 did not use Mix_Init(). You should add it prior OpenAudio
for 1.2.11 usage.

That’s extremely helpful. However, I need the code to still work with
1.2.8. What is the recommended way to keep my code compatible?

For an autoconf-using project, I guess I should add Mix_Init to my
AC_CHECK_FUNCS, and then in the source code surround the call to
Mix_Init() with #ifdef HAVE_MIX_INIT?

Thanks,

David Bruce

Hi Ronald,

SDL-mixer 1.2.8 did not use Mix_Init(). You should add it prior OpenAudio
for 1.2.11 usage.

That’s extremely helpful. However, I need the code to still work with
1.2.8. What is the recommended way to keep my code compatible?

Try calling Mix_Linked_Version, so you can know whether or not you’ll
need to call Mix_Init.>----- Original Message ----

From: David Bruce
Subject: Re: [SDL] Unexpected exit at first SDL_mixer call (v1.2.11 in mingw-cross-env)

Hi,Am 02.03.2010 19:05, schrieb David Bruce:

Hi Ronald,

SDL-mixer 1.2.8 did not use Mix_Init(). You should add it prior OpenAudio
for 1.2.11 usage.

That’s extremely helpful. However, I need the code to still work with
1.2.8. What is the recommended way to keep my code compatible?

For an autoconf-using project, I guess I should add Mix_Init to my
AC_CHECK_FUNCS, and then in the source code surround the call to
Mix_Init() with #ifdef HAVE_MIX_INIT?

The code I added to our Enigma project (http://www.nongnu.org/enigma):

configure.ac:

dnl ----------------------------------------
dnl Check for SDL mixer library
dnl ----------------------------------------
AC_CHECK_LIB(SDL_mixer,main,[AC_MSG_ERROR([SDL_mixer is required to
compile Enigma])])

SDL_LIBS="$SDL_LIBS -lSDL_mixer"

AC_CHECK_LIB(SDL_mixer, Mix_QuickLoad_RAW, have_mix_quickload=“yes”,
have_mix_quickload=“no”)
if test “$have_mix_quickload” = no; then
AC_MSG_ERROR([SDL_mixer >= 1.2.5 is required to compile Enigma])
fi

AC_CHECK_LIB(SDL_mixer, Mix_Init, have_mix_init=“yes”, have_mix_init=“no”)
if test “$have_mix_init” = yes; then
AC_DEFINE(SDL_MIX_INIT, , [Whether SDL_mixer library provides init])
fi

src/SoundEngine.cc :

     // Initialize SDL audio subsystem
     if (SDL_InitSubSystem (SDL_INIT_AUDIO) == -1) {
         fprintf(stderr, "Couldn't open SDL audio subsystem: %s\n", 

SDL_GetError());
return false;
}

     const SDL_version* vi = Mix_Linked_Version();
     Log <<  ecl::strf("SDL_mixer Version: %u.%u.%u\n", vi->major, 

vi->minor, vi->patch);
#ifdef SDL_MIX_INIT
int mix_flags = MIX_INIT_OGG | MIX_INIT_MOD;
if (Mix_Init(mix_flags) & mix_flags != mix_flags) {
Log << ecl::strf( “Couldn’t initialize SDL_mixer: %s\n”,
Mix_GetError());
return false;
}
#endif

     // Initialize SDL_mixer lib
     if (Mix_OpenAudio(m_freq, m_format, m_channels, 1024) < 0) {
         fprintf(stderr, "Couldn't open mixer: %s\n", Mix_GetError());
         return false;
     }

Greets,

Ronald

Hi Ronald et al,

SDL-mixer 1.2.8 did not use Mix_Init(). You should add it prior OpenAudio
for 1.2.11 usage.

I added the call to Mix_Init() (along with some Autoconf stuff to only
call it for SDL-mixer 1.2.10 and later), but unfortunately it did not
fix the problem. The mingw cross-build of the program still exits
silently at the first call to Mix_OpenAudio().

So I guess I need to create a small test case to get to the bottom of this.

Thanks,

David Bruce

Hi,

My message got bounced because the attached tarball made it too big,
so I’m sending it without the tarball. The contents of main.c are in
the body of the message anyway. I’d be happy to send the tarball
off-list to anyone who wants it.

DSB---------- Forwarded message ----------
From: @David_Bruce (David Bruce)
Date: Thu, Mar 4, 2010 at 2:28 PM
Subject: Re: [SDL] Unexpected exit at first SDL_mixer call (v1.2.11 in
mingw-cross-env)
To: SDL Development List

Hi everyone,

I made a test case program for the problem I have been having with
SDL-mixer-1.2.11 in a cross-compiled program. ?Basically, since
tuxtype uses autotools, I used the “amhello” example bundled with
automake and added enough code to try to initialize SDL and SDL-mixer.
?I copied the relevant portions of tuxtype’s configure.ac into
amhello’s configure.ac to handle detection and linking of the needed
libraries. ?The contents of main.c are below. ?Also, I have attached
the source tree of this small program in tarball form.

The crossbuild was done on an Ubuntu 9.10 machine using the
ming-cross-env environment (http://mingw-cross-env.nongnu.org), which
produces a statically linked binary instead of using dlls.

When compiled for linux, all of the output is as expected. ?On
windows, it is very puzzling. ?If I comment out the call to
Mix_OpenAudio(), the output is as expected (redirected into stdout.txt
as seems usual on Windows). ?This includes output confirming that
Mix_Init() succeeded. ?However, if Mix_OpenAudio() gets called, the
program only produces zero-byte stdout.txt and stderr.txt files, not
even containing the output of the printf statements that preceded
Mix_OpenAudio().

I hope someone has some ideas, as I am really at a loss how to proceed further.

As always, thanks!

David Bruce

Contents of main.c:

#include <config.h>
#include <stdio.h>

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

int main(int argc, char *argv[])
{
?puts (“Hello World!”);
?puts ("This is " PACKAGE_STRING “.”);

?/* Begin SDL and SDL_mixer init code from tuxtype: */

?printf( “LibInit():\n-About to init SDL Library\n” );

?/* Initialize video: /
?if (SDL_Init(SDL_INIT_VIDEO) < 0)
?{
? ?printf(“Couldn’t initialize SDL: %s\n”,
? ? ? ? ? SDL_GetError());
? ?exit(2);
?}
?/
Initialize audio: */
?if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
?{
? ?printf(“Couldn’t initialize SDL Sound: %s\n”,
? ? ? ? ? SDL_GetError());
? ?exit(2);
?}

?printf(“SDL video and audio initialized\n”);

?/* Only call Mix_Init() if available, i.e. version >= 1.2.10 */

#ifdef HAVE_MIX_INIT
?int initted;

?printf(“About to call Mix_Init():\n”);

?initted = Mix_Init(MIX_INIT_OGG);

?/* We must have Ogg support to have sound: */
?if((initted & MIX_INIT_OGG) != MIX_INIT_OGG)
?{
? ?printf(“Mix_Init: Failed to init required ogg support!\n”);
? ?printf(“Mix_Init: %s\n”, Mix_GetError());
? ?exit(2);
?}

?printf(“Mix_Init() succeeded.\n”);

#else
?printf(“Mix_Init() not detected by configure script.\n”);
#endif

?/* If Mix_Init() succeeded (or wasn’t required), set audio parameters: */
?printf(“About to call Mix_OpenAudio():\n”);

// NOTE: if the next statement is commented out, the program
// produces the expected output on both Linux and Windows,
// but if the Mix_OpenAudio() call takes place,
// the Windows build produces no output, even from the above printf’s.
// I don’t understand this.

?if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048) == -1)
? ?printf(“Warning: Mix_OpenAudio() failed\n”);
?else
? ?printf(“Mix_OpenAudio() successful\n”);

?return 0;
}

Hi everyone,

I tried to send this last night but I’m not sure if it got through
(the original message was rejected because I had attached the tarball
file.) I apologize if you are getting a duplicate.

In lieu of the tarball attachment, I have put the test program in a
publicly-accessible git repo at:

git://git.debian.org/git/tux4kids/amhello

Anyway, I made a test case program for the problem I have been having with
SDL-mixer-1.2.11 in a cross-compiled program. Basically, since
tuxtype uses autotools, I used the “amhello” example bundled with
automake and added enough code to try to initialize SDL and SDL-mixer.
I copied the relevant portions of tuxtype’s configure.ac into
amhello’s configure.ac to handle detection and linking of the needed
libraries. The contents of main.c are below.

The crossbuild was done on an Ubuntu 9.10 machine using the
ming-cross-env environment (http://mingw-cross-env.nongnu.org), which
produces a statically linked binary instead of using dlls.

When compiled for linux, all of the output is as expected. On
windows, it is very puzzling. If I comment out the call to
Mix_OpenAudio(), the output is as expected (redirected into stdout.txt
as seems usual on Windows). This includes output confirming that
Mix_Init() succeeded. However, if Mix_OpenAudio() gets called, the
program only produces zero-byte stdout.txt and stderr.txt files, not
even containing the output of the printf statements that preceded
Mix_OpenAudio().

I hope someone has some ideas, as I am really at a loss how to proceed
further. Should I just downgrade SDL-mixer to 1.2.8 in my crossbuild
setup?

As always, thanks!

David Bruce

Contents of main.c:

#include <config.h>
#include <stdio.h>

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

int main(int argc, char *argv[])
{
puts (“Hello World!”);
puts ("This is " PACKAGE_STRING “.”);

/* Begin SDL and SDL_mixer init code from tuxtype: */

printf( “LibInit():\n-About to init SDL Library\n” );

/* Initialize video: /
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf(“Couldn’t initialize SDL: %s\n”,
SDL_GetError());
exit(2);
}
/
Initialize audio: */
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
{
printf(“Couldn’t initialize SDL Sound: %s\n”,
SDL_GetError());
exit(2);
}

printf(“SDL video and audio initialized\n”);

/* Only call Mix_Init() if available, i.e. version >= 1.2.10 */

#ifdef HAVE_MIX_INIT
int initted;

printf(“About to call Mix_Init():\n”);

initted = Mix_Init(MIX_INIT_OGG);

/* We must have Ogg support to have sound: */
if((initted & MIX_INIT_OGG) != MIX_INIT_OGG)
{
printf(“Mix_Init: Failed to init required ogg support!\n”);
printf(“Mix_Init: %s\n”, Mix_GetError());
exit(2);
}

printf(“Mix_Init() succeeded.\n”);

#else
printf(“Mix_Init() not detected by configure script.\n”);
#endif

/* If Mix_Init() succeeded (or wasn’t required), set audio parameters: */
printf(“About to call Mix_OpenAudio():\n”);

// NOTE: if the next statement is commented out, the program
// produces the expected output on both Linux and Windows,
// but if the Mix_OpenAudio() call takes place,
// the Windows build produces no output, even from the above printf’s.
// I don’t understand this.

if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048) == -1)
printf(“Warning: Mix_OpenAudio() failed\n”);
else
printf(“Mix_OpenAudio() successful\n”);

return 0;
}

Hi,

Anyway, I made a test case program for the problem I have been having with
SDL-mixer-1.2.11 in a cross-compiled program. Basically, since
tuxtype uses autotools, I used the “amhello” example bundled with
automake and added enough code to try to initialize SDL and SDL-mixer.
I copied the relevant portions of tuxtype’s configure.ac into
amhello’s configure.ac to handle detection and linking of the needed
libraries. The contents of main.c are below.

The crossbuild was done on an Ubuntu 9.10 machine using the
ming-cross-env environment (http://mingw-cross-env.nongnu.org), which
produces a statically linked binary instead of using dlls.

Having currently no Ubuntu 9.10 installation ready for testing purposes
I just can provide some hints and guesses as no one else did answer this
request.

Even when linked statically to SDL-mixer-1.2.11 your app will require
libogg-0.dll, libvorbis-0.dll and libvorbisfile-3.dll.

In case you link to SDL-mixer-1.2.10 you will require additionally
mikmod.dll due to an intialization crashing bug in this release. You may
even try to add this dll to an 1.2.11 release - just in case of
remaining problems.

When compiled for linux, all of the output is as expected. On
windows, it is very puzzling. If I comment out the call to
Mix_OpenAudio(), the output is as expected (redirected into stdout.txt
as seems usual on Windows). This includes output confirming that
Mix_Init() succeeded. However, if Mix_OpenAudio() gets called, the
program only produces zero-byte stdout.txt and stderr.txt files, not
even containing the output of the printf statements that preceded
Mix_OpenAudio().

Stdout will not be flushed in case of exceptions. Debugging output
should be written to stderr. It looks like Mix_OpenAudio throws an
exception. You can either catch and evaluate it or you can execute your
test app in gdb.

Greets,

RonaldAm 05.03.2010 17:20, schrieb David Bruce:

Hi Ronald,

Even when linked statically to SDL-mixer-1.2.11 your app will require
libogg-0.dll, libvorbis-0.dll and libvorbisfile-3.dll.

mingw-cross-env builds everything statically and links it all
together. Here is the link stage command from the build of my
modified amhello:

i686-pc-mingw32-gcc -g -O2 -D_GNU_SOURCE=1 -Dmain=SDL_main
-I/opt/mingw-cross-env/usr/i686-pc-mingw32/include/SDL
-I/opt/mingw-cross-env/usr/i686-pc-mingw32/include
-L/opt/mingw-cross-env/usr/i686-pc-mingw32/lib -o hello.exe main.o
-mwindows -L/opt/mingw-cross-env/usr/i686-pc-mingw32/lib -lSDL_mixer
-lmikmod -lpthread -lws2_32 -lsmpeg -lstdc++ -lmingw32 -lSDLmain -lSDL
-liconv -luser32 -lgdi32 -lwinmm -ldxguid -lvorbisfile -lvorbis -lm
-logg

Is there something about sdl_mixer that won’t allow it to work if all
the libraries used by the program, including sdl_mixer’s dependencies,
are linked together statically?

Stdout will not be flushed in case of exceptions. Debugging output should be
written to stderr.

Thanks, that’s good to know. I changed all the printf’s accordingly.

It looks like Mix_OpenAudio throws an exception. You can
either catch and evaluate it or you can execute your test app in gdb.

So I would need a mingw build of gdb, right? This problem only shows
up when I run the cross-built program on Windows.

Thanks for any help,

David BruceOn Sat, Mar 6, 2010 at 1:52 PM, Ronald Lamprecht <R.Lamprecht at t-online.de> wrote: