Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] Re: (PR#2700) SDL_init can only be called once
Home

[Freeciv-Dev] Re: (PR#2700) SDL_init can only be called once

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2700) SDL_init can only be called once
From: "Rafa³ Bursig via RT" <rt@xxxxxxxxxxxxxx>
Date: Thu, 2 Jan 2003 02:42:00 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Dnia 2003.01.02 02:32 Jason Short via RT napisa³(a):
> 
> SDL_init() cannot generally be called more than once.  Even if you
> uninitialize SDL, you can't call it again.  And this means SDL sound
> doesn't work with the SDL client, since both call SDL_init.
> 
> The fix should introduce a common client method of initializing SDL.
> Something like init_sdl(options) which will only initialize once.  And
> SDL should not be uninitted until the client exits (for instance when
> we
> uninitialize a sound module it should not be done, since we may switch
> back to that sound module later).
> 
> autoconf changes may also be needed to see if any SDL users are being
> compiled.  The check could be something like
>   #if defined SDL_AUDIO or defined SDL_CLIENT
> or
>   #ifdef USING_SDL
> 
> A patch for this would be welcome.
> 
This problem is secound on my TODO list ( after small stabilization of 
draw code ).
We don't need any global init variables or function.
I plan use SDL function SDL_WasInit( SDL_Init_Flags ) which rerun init 
flags status.
Should look like :

init of sound in SDL output module exp.

if ( SDL_WasInit( SDL_INIT_VIDEO ))
{
   /* Initialize the sound subsystem */
   if (SDL_InitSubSystem( SDL_INIT_AUDIO ))
   {
      /* Fail */
       abort();
    }
}
else
{
   /* Initialize the sound system */
   if ( SDL_Init( SDL_INIT_AUDIO ))
   {
      /* Fail */
       abort();
    }
}

init of video in SDLClient exp.

if ( SDL_WasInit( SDL_INIT_AUDIO ))
{
   /* Initialize the video subsystem */
   if (SDL_InitSubSystem( SDL_INIT_VIDEO ))
   {
      /* Fail */
       abort();
    }
}
else
{
   /* Initialize the video system */
   if ( SDL_Init( SDL_INIT_VIDEO ))
   {
      /* Fail */
       abort();
    }
}

Rafal

----------------------------------------------------------------------
Portal INTERIA.PL zaprasza... >>> http://link.interia.pl/f16ab 





[Prev in Thread] Current Thread [Next in Thread]