Why this crash after a fiew hours -niewbie-

Hello i make this small program to listen mp3 music from text file
but it crash after a fiew hours if i put over 500 songs in text file
my problem is i run out of memory

here is this small program

#include <SDL.h>
#include <smpeg/smpeg.h>
#include
#include

#define NEXTM 180 // next music

using namespace std;

SDL_Surface * screen;
SMPEG *mpeg;
SMPEG_Info info;
SDL_Event event;
int done;

int main(int argc, char * argv[])
{
if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO ) < 0) {
cout << “Unable to init SDL” << endl;
exit(1);
}

screen = SDL_SetVideoMode(300, 200, 24, SDL_SWSURFACE);
   if ( screen == NULL ) {
       cout << "Couldn't set video mode" << endl;
       exit(1);
      }

ifstream music_in (“Data/mp3text”, ios::in);
if(!music_in) {
cout << “cannot open mp3text.\n”;
return 1;
}

char musicin[250];
musicin[250] = ‘\0’;

time_t lasttimem = time(NULL)-NEXTM;

while (!done & !music_in.eof()){

if (time(NULL)>lasttimem+NEXTM){

if (mpeg == NULL) {
}
else if (mpeg){
//free(mpeg);
SMPEG_delete(mpeg);
cout << "Delete: " << musicin << endl;
}
music_in.getline(musicin, 239);
mpeg = SMPEG_new(musicin, &info, 1);
SMPEG_enableaudio(mpeg, 1);
SMPEG_setvolume(mpeg, 100);

  if (info.has_audio){
           printf("Now play: %s: MPEG audio stream\n", musicin );
         if (info.has_audio)
              printf("\tAudio %s\n", info.audio_string);
            if (info.total_size)
                 printf("\tSize: %d\n", info.total_size);
                    if (info.total_time)
                        printf("\tTotal time: %f\n", info.total_time);
                 SMPEG_play(mpeg);
               }

           lasttimem = time(NULL);
          }

while (SDL_PollEvent(&event))
{
  if (event.type == SDL_QUIT)
done = 1;

else if (event.type == SDL_KEYDOWN)
{
if (event.key.keysym.sym == SDLK_ESCAPE)
done = 1;

  else if (event.key.keysym.sym == SDLK_s)
        SMPEG_stop(mpeg);

  else if (event.key.keysym.sym == SDLK_p)
         SMPEG_play(mpeg);
        }
   }

}

SMPEG_stop(mpeg);
SMPEG_delete(mpeg);
return(0);
}

why i run out of memory? help pls.

BTW: in info.total_time i see the time like this " Total time:
230.416750"
how can i see in seconds

ppap_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus

Looks to me like there’s a memory leak in SMPEG. I have discovered a
few other issues with smpeg (e.g. I get audible errors in some of my
mp3 files which don’t show up in other players), so I guess it’s time
to look for a new mp3 decoder library (note: the mpglib packaged with
SDL_sound is even more useless than smpeg).

Any recommendations?

  • AndreasOn Fri, 17 Sep 2004 14:11:14 +0300, petros ppap wrote:

Hello i make this small program to listen mp3 music from text file
but it crash after a fiew hours if i put over 500 songs in text file
my problem is i run out of memory

Andreas Umbach wrote:

Looks to me like there’s a memory leak in SMPEG. I have discovered a
few other issues with smpeg (e.g. I get audible errors in some of my
mp3 files which don’t show up in other players), so I guess it’s time
to look for a new mp3 decoder library (note: the mpglib packaged with
SDL_sound is even more useless than smpeg).

Any recommendations?

There is ffmpeg (http://ffmpeg.sourceforge.net/) but I can’t really
recommend it. It doesn’t support the gnu autotools, it’s very
cluttered and you have to code a lot more code yourself to get a working
mp3 player.

Bye,
Michael Prager

Looks to me like there’s a memory leak in SMPEG. I have discovered a
few other issues with smpeg (e.g. I get audible errors in some of my
mp3 files which don’t show up in other players), so I guess it’s time
to look for a new mp3 decoder library (note: the mpglib packaged with
SDL_sound is even more useless than smpeg).

Any recommendations?

  • AndreasOn Fri, 17 Sep 2004 14:11:14 +0300, petros ppap wrote:

Hello i make this small program to listen mp3 music from text file
but it crash after a fiew hours if i put over 500 songs in text file
my problem is i run out of memory

Andreas Umbach wrote:

Looks to me like there’s a memory leak in SMPEG. I have discovered a
few other issues with smpeg (e.g. I get audible errors in some of my
mp3 files which don’t show up in other players), so I guess it’s time
to look for a new mp3 decoder library (note: the mpglib packaged with
SDL_sound is even more useless than smpeg).

Any recommendations?

There is ffmpeg (http://ffmpeg.sourceforge.net/) but I can’t really
recommend it. It doesn’t support the gnu autotools, it’s very
cluttered and you have to code a lot more code yourself to get a
working mp3 player.

If ffmpeg’s core logic is fundamentally superior to SMPEG, why don’t we
look forward into making it better? Or maybe someone could fix the
problems with SMPEG? Can someone contact the SMPEG maintainers? Or the
ffmpeg maintainers?On Sep 20, 2004, at 9:28 AM, Michael Prager wrote:

Bye,
Michael Prager


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

Donny Viszneki wrote:

If ffmpeg’s core logic is fundamentally superior to SMPEG, why don’t
we look forward into making it better?

I personally don’t think the maintainers of ffmpeg intend to improve the
structure, otherwise they would have done that years ago.

Or maybe someone could fix the problems with SMPEG? Can someone
contact the SMPEG maintainers?

Tried that a couple of days ago. It’s very hard to reach someone.
Activity on the mailing list doesn’t even exist. There is however a CVS
version on http://www.icculus.org/smpeg/, maybe that fixes some of the
problems (I couldn’t get it compiled with current SDL CVS though).

Bye,
Michael Prager

Actually, Ryan Gordon (icculus) is very helpful in dealing with SMPEG.
I haven’t compiled smpeg in a while, but I didn’t encounter any issues
when I did it the last time (and the library isn’t changing at a rapid
pace…). However, SMPEG is a little bloated, so what exactly would
you try to improve?

  • Andreas

Andreas Umbach wrote:

Actually, Ryan Gordon (icculus) is very helpful in dealing with SMPEG.
I haven’t compiled smpeg in a while, but I didn’t encounter any issues
when I did it the last time (and the library isn’t changing at a rapid
pace…). However, SMPEG is a little bloated, so what exactly would
you try to improve?

Here are a few things that bothered me:

  • it’s still using old version of automake (1.4 I think), doesn’t work
    with automake1.7 and newer
  • screen stays black screen when running on Windows with SDL 1.2.7 and
    DirectX Support. The only way to get it working is to compile SDL with
    the -DUSE_DIRECTX_OVERLAY
  • doesn’t compile with MinGW and msys. The following patch is required
    to get it working:

— src/Makefile.am.old Mon Nov 10 06:08:02 2003
+++ src/Makefile.am Thu Sep 9 01:07:30 2004
@@ -7,7 +7,7 @@
lib_LTLIBRARIES = libogg.la

libogg_la_SOURCES = framing.c bitwise.c
-libogg_la_LDFLAGS = -no-undefined -version-info
@LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
+libogg_la_LDFLAGS = --no-undefined -version-info
@LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@

and finally I have a problem on Linux when running any app using smpeg.
For example when I run plaympeg, the app crashes with

X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 141 (XVideo)
Minor opcode of failed request: 19 ()
Serial number of failed request: 19
Current serial number in output stream: 20

The only way to get such apps working is to set the following
environment variable:
XLIB_SKIP_ARGB_VISUALS=1

Maybe this is related to my system, I’m using Gentoo unstable.
http://dict.tu-chemnitz.de/dings.cgi?o=3003;count=50;service=en-de;query=bother