GP2X Using Sdl_mixer


nickspoon

vultum stultum habes
Joined
Nov 4, 2005
Messages
4,234
Age
32
Location
Essex, UK
Website
Visit site
I've been having a bit of trouble with SDL_mixer, and through linking all of its dependencies I've ended up with:

-lSDLmain -lSDL_mixer -lsmpeg -lvorbisfile -lpthread -lvorbis -logg -lmikmod -lSDL

That looks an awful lot, but seems to do everything.

Unfortunately, I now get:
mdriver.c:(.text+0x2970): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

What does this mean? Not having a GP2X to test it on, I don't know if it affects anything, but what exactly is it?
 
Ignore the error, it still works fine ;) (well, as long as you don't use whatever function that warning is refering to I suppose, but I've had no problems myself)
 
Nickspoon, thanks for telling us how to link. Now, my app it compiles and links (showing that warning).

woogal posted on Dec 3 2005 at 09:03 PM said:
Ignore the error, it still works fine ;) (well, as long as you don't use whatever function that warning is refering to I suppose, but I've had no problems myself)

Woogal, after seeing it links, I've tested it on GP2X but I get a black screen, then the mouse cursor is shown during some milliseconds, and then completely black again. All I'm doing is to call Mix_OpenAudio like this:
Code:
Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 2048)
Nothing more (not trying to play sounds yet). You say you've had no problems, so I wonder if you could post here that call from your working app. I've executed "install_libs.gpu" to install SDL libs on my GP2X and my app without that call works. Thanks.
 
Last edited by a moderator:
I'm using Mix_OpenAudio(22050, AUDIO_S16, 2, 4096), but I can't see why your openaudio would fail. If you still can't get it to work then if you send me your app I can run it with a serial lead connected and let you know what the error is. Oh, and you probably don't need to install the libs on your gp2x - that's just for NK's games. Your app will more than likely either use the libs that came on the device (if you're using the gcc supplied by GPH), or the SDL libs will be included in the exe (if you're using one of the gcc 4 versions that are around).
 
woogal posted on Dec 3 2005 at 11:52 PM said:
I'm using Mix_OpenAudio(22050, AUDIO_S16, 2, 4096), but I can't see why your openaudio would fail. If you still can't get it to work then if you send me your app I can run it with a serial lead connected and let you know what the error is.

Very nice of you. One silly question: how can I send it to you? I see no way of attaching files here and it's already on the net (Tilematch game) but that version doesn't call Mix_OpenAudio.

woogal posted on Dec 3 2005 at 11:52 PM said:
Oh, and you probably don't need to install the libs on your gp2x - that's just for NK's games. Your app will more than likely either use the libs that came on the device (if you're using the gcc supplied by GPH), or the SDL libs will be included in the exe (if you're using one of the gcc 4 versions that are around).

Ok. I thought those libs where needed in order to use any SDL app. My Makefile uses the compiler from WinterMute's DevKit and links statically so I'm not sure but I guess it doesn't need any SDL libs to be installed.
 
Last edited by a moderator:
I have a similar problem.

My program compiles with the warning you talked about before, it executes perfectly in the GP2X, but there is any sound.

The same program plays sounds perfectly in Linux and GP32 so I don't know where is the problem :huh:

My sound code is:

Code:
Mix_Chunk *sound_end;
Mix_OpenAudio(22050, AUDIO_S16, 2, 4096);
sound_end=Mix_LoadWAV_RW(SDL_RWFromMem(&send,sizeof(send)),0);
Mix_PlayChannel(-1,sound_end,0);

Any idea about what is wrong?

Thanks a lot :)
 
I have trouble linking sdl_mixer myself. I have the same warning and more errors:

Code:
/home/kim/gp2xdev/lib/libmikmod.a(mdriver.o): In function `MD_DropPrivileges':
mdriver.c:(.text+0x2970): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/kim/gp2xdev/lib/libSDL_mixer.a(mixer.o): In function `mix_channels':
mixer.c:(.text+0x7f4): undefined reference to `SDL_MixAudio'
mixer.c:(.text+0xa5c): undefined reference to `SDL_MixAudio'
...

it seems that I amissing some thing. I link with following:

Code:
-static -L$(ARMDIR)/lib -L$(ARMDIR)/arm-open2x-linux/lib -lSDLmain -lSDL -lSDL_mixer -lpthread -lvorbis -logg -lmikmod -lsmpeg -lvorbisfile -lvorbisenc -lm -lg -lgcc

only graphics with -lSDL works like a treat. i use he libs coming with open2x toolchain. What am I over looking here? (This is my Makefile
 
woogal posted on Dec 3 2005 at 09:52 PM said:
I'm using Mix_OpenAudio(22050, AUDIO_S16, 2, 4096), but I can't see why your openaudio would fail. If you still can't get it to work then if you send me your app I can run it with a serial lead connected and let you know what the error is. Oh, and you probably don't need to install the libs on your gp2x - that's just for NK's games. Your app will more than likely either use the libs that came on the device (if you're using the gcc supplied by GPH), or the SDL libs will be included in the exe (if you're using one of the gcc 4 versions that are around).

Are you building your stuff on Linux or on Windows?
 
Last edited by a moderator:
miq01 posted on Dec 4 2005 at 12:44 AM said:
Very nice of you. One silly question: how can I send it to you?
Email it to woogal@sector808.org

evening2005 posted on Dec 5 2005 at 05:55 PM said:
Are you building your stuff on Linux or on Windows?
Linux.
 
Last edited by a moderator:
I'm having the same problem as mig01, using SDL_mixer with those things doesn't work properly for some reason, the program just crashes.
 
woogal posted on Dec 5 2005 at 05:58 PM said:
miq01 posted on Dec 4 2005 at 12:44 AM said:
Very nice of you. One silly question: how can I send it to you?
Email it to woogal@sector808.org

evening2005 posted on Dec 5 2005 at 05:55 PM said:
Are you building your stuff on Linux or on Windows?
Linux.
If you manage to diagnose miq01's problem, I'm sure there are others here who would love to know what it is!

Cheers
 
Last edited by a moderator:
Sorry for this long post... :)

Ok. I've sent my SDL_Mixer test to Woogal. It works on XP building it with Code::Blocks (mingw32), but it doesn't on GP2X building it with WinterMute's DevKit on Cygwin.

For your information, my code looks like this:
Code:
#include "SDL.h"
#include "SDL_Mixer.h"

int main (int argc, char** argv)
{
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK)<0)
    {
        printf("SDL_Init: %s\n", SDL_GetError());
        return 1;
    }

    SDL_Joystick *joystick = SDL_JoystickOpen(0);

    SDL_Surface* screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);
    if (!screen)
    {
        printf("SDL_SetVideoMode: %s\n", SDL_GetError());
        return 1;
    }

    if (Mix_OpenAudio(22050, AUDIO_S16, 2, 4096)==-1)
    {
        printf("Mix_OpenAudio: %s\n", Mix_GetError());
        return 1;
    }

    Mix_Chunk* sample = Mix_LoadWAV("sample.ogg");
    if (!sample)
    {
        printf("Mix_LoadWAV: %s\n", Mix_GetError());
        return 1;
    }

    if (Mix_PlayChannel(0, sample, 0)==-1)
    {
        printf("Mix_PlayChannel: %s\n", Mix_GetError());
        return 1;
    }

    bool done = false;
    while (!done)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            if (event.type==SDL_KEYDOWN)
                if (event.key.keysym.sym == SDLK_ESCAPE)
                    done = true;
            if (event.type==SDL_JOYBUTTONDOWN)
                done = true;
        }

        SDL_Flip(screen);
    }

    SDL_JoystickClose(joystick);
    Mix_FreeChunk(sample);
    Mix_CloseAudio();

    return 0;
}

This is the Makefile:
Code:
CROSS_COMPILE = C:/devkitGP2X/bin/arm-linux-
SDL_BASE = C:/devkitGP2X/bin/arm-linux-
LDFLAGS = -static

CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
STRIP = $(CROSS_COMPILE)strip

CFLAGS = `$(SDL_BASE)sdl-config --cflags` -O2 -fexpensive-optimizations -Wall
CXXFLAGS = `$(SDL_BASE)sdl-config --cflags` -DTARGET_GP2X -O2 -fexpensive-optimizations -Wall
LIBS = -LC:/devkitGP2X/lib -lSDLmain -lSDL_mixer -lsmpeg -lvorbisfile -lpthread -lvorbis -logg -lmikmod -lSDL

TARGET = sdlmixer.gpe
OBJS = main.o

ALL_TARGETS = $(TARGET)

all: $(ALL_TARGETS)

$(TARGET): $(OBJS)
    $(CXX) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
    $(STRIP) $(TARGET)

If you want to try, replace "C:/devkitGP2X/lib" with your path to the DevKit libs, and add a file called "sample.ogg" in the same folder as the executable. On XP, quit by pressing the ESC key. On GP2X it should quit by pressing any button.
 
Well, the error message from miq01's app is - 'Mix_OpenAudio: Couldn't create mixer lock'. Not sure what the hell could be causing that but it seems like it might be a problem with the sdl_mixer lib being used. I don't have access to my dev machine at the moment so I can't try recompiling miq01's code, but a version of the lib I compiled myself is at http://gp2x.sector808.org/libSDL_mixer.a if anyone wants to try using it. That's quite old now so I'm not sure if it includes ogg support, but wav's and mod's should work with it. If it seems to work better for people I'll upload my latest compile tomorrow (which definately does include ogg support).
 
woogal posted on Dec 7 2005 at 12:34 AM said:
Well, the error message from miq01's app is - 'Mix_OpenAudio: Couldn't create mixer lock'. Not sure what the hell could be causing that but it seems like it might be a problem with the sdl_mixer lib being used. I don't have access to my dev machine at the moment so I can't try recompiling miq01's code, but a version of the lib I compiled myself is at http://gp2x.sector808.org/libSDL_mixer.a if anyone wants to try using it. That's quite old now so I'm not sure if it includes ogg support, but wav's and mod's should work with it. If it seems to work better for people I'll upload my latest compile tomorrow (which definately does include ogg support).

Thanks woogal, I will try it.

At the moment I can tell you that the library size is quite different (300 KBs mine and 1,6 MB yours) :)

I will tell you if it works now :rolleyes:
 
Last edited by a moderator:
Ey, woogal, I have tried to play a .xm mod file, but it doesn't work.

The good thing is that wav audio files play clearly :)

You are great man! ;)

EDIT: Please, upload your last SDL_mixer version :)
 
woogal posted on Dec 7 2005 at 01:34 AM said:
Well, the error message from miq01's app is - 'Mix_OpenAudio: Couldn't create mixer lock'. Not sure what the hell could be causing that but it seems like it might be a problem with the sdl_mixer lib being used. I don't have access to my dev machine at the moment so I can't try recompiling miq01's code, but a version of the lib I compiled myself is at http://gp2x.sector808.org/libSDL_mixer.a if anyone wants to try using it. That's quite old now so I'm not sure if it includes ogg support, but wav's and mod's should work with it. If it seems to work better for people I'll upload my latest compile tomorrow (which definately does include ogg support).

This is great news! It worked! It doesn't play OGGs but I've converted the file into WAV format and certainly sounds!

Thank you very much, Woogal.

Edit: Doesn't play MP3 either.
 
Last edited by a moderator:
Well... after compiling the test I sent to Woogal with the new SDL_mixer lib, I've decided to check if Tilematch could, at least, open the mixer device. The good news is that it does. The bad news is that something completely messes up key mappings: JOYUP and JOYDOWN stop responding, and A and X buttons work as UP and DOWN. Other buttons don't respond either. My guess is that it has to do with SDL_mixer, even though I know it sounds really weird, because removing SDL_mixer calls makes it work again. Any ideas? Maybe it means we'll have to wait for a new release of the DevKit for Windows...
 
Puck2099 posted on Dec 7 2005 at 12:12 AM said:
Ey, woogal, I have tried to play a .xm mod file, but it doesn't work.
Quite possible. I only compiled it to get mod, wav and voc working and didn't test with anything else (some stuff had to be left out of the configure to get it to work and I can't remember exactly what they were).

miq01 posted on Dec 7 2005 at 12:48 AM said:
Doesn't play MP3 either.
SDL_Mixer uses smpeg to play mp3's, which I haven't compiled for the gp2x. The best thing to use for mp3 would be libmad which is optimised for fixed point chips (unlike smpeg).

miq01 posted on Dec 7 2005 at 02:22 AM said:
Well... after compiling the test I sent to Woogal with the new SDL_mixer lib, I've decided to check if Tilematch could, at least, open the mixer device. The good news is that it does. The bad news is that something completely messes up key mappings: JOYUP and JOYDOWN stop responding, and A and X buttons work as UP and DOWN. Other buttons don't respond either. My guess is that it has to do with SDL_mixer, even though I know it sounds really weird, because removing SDL_mixer calls makes it work again. Any ideas? Maybe it means we'll have to wait for a new release of the DevKit for Windows...
I think with the huge size difference between my lib and the old one, it must have got carried away and also included my version of libsdl for some reason. With my sdl build I played around with the joystick (GPH had made a complete mess of things) but never bothered finishing it because I decided to support keys instead (don't have a joystick for the pc, so if the gp2x responds to keys then I can test the same code on a pc and the gp2x (and also the gp32 which maps the stick to keys)). I'll have a play tonight and try and get a mixer version that works but doesn't mess other things up.
 
Last edited by a moderator:
Back
Top