rnd-20001128-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 28 Nov 2000 21:03:59 +0000 (22:03 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:35:12 +0000 (10:35 +0200)
13 files changed:
Makefile
src/Makefile
src/game.c
src/init.c
src/main.c
src/main.h
src/msdos.c
src/platform.h
src/screens.c
src/sound.c
src/sound.h
src/system.c
src/system.h

index 82094534cd33948f2521947f2d821e5c77f5184e..cf775274d67af633249720d5c09d13da35cfa659 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,9 +25,6 @@ X11_PATH = /usr/X11
 # uncomment this if your system has no joystick include file
 # JOYSTICK = -DNO_JOYSTICK
 
-# uncomment this if your system has no sound
-# SOUNDS = -DNO_SOUNDS
-
 # choose if you want to allow many global score file entries for one player
 # default is 'MANY_PER_NAME'
 # when installing the game in a multi user environment, choose this
index 4dc153094bd849ac6aba3693ba4c927ae72e9de3..cc8e1df0439b9abf95affa76278759f823248dc1 100644 (file)
@@ -84,7 +84,7 @@ endif
 CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
 
 
-CONFIG = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(SOUNDS) $(JOYSTICK)
+CONFIG = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(JOYSTICK)
 DEBUG = -DDEBUG -g
 
 OPTIONS = $(DEBUG) -Wall                       # only for debugging purposes
@@ -93,6 +93,7 @@ OPTIONS = $(DEBUG) -Wall                      # only for debugging purposes
 # OPTIONS = -O3 -Wall -ansi -pedantic
 # OPTIONS = -O3 -Wall
 # OPTIONS = -O3
+# OPTIONS = -DSYSV -Ae                         # may be needed for HP-UX
 
 CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG)
 LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
index 708021370a7ad3070709730611f4f61edb6225fb..1f3aca0024d71c3808c3be9853326d37586b7f1b 100644 (file)
@@ -167,10 +167,10 @@ static unsigned int getStateCheckSum(int counter)
 
 void GetPlayerConfig()
 {
-  if (sound_status == SOUND_OFF)
+  if (!sysinfo.audio_available)
     setup.sound = FALSE;
 
-  if (!sound_loops_allowed)
+  if (!sysinfo.audio_loops_available)
   {
     setup.sound_loops = FALSE;
     setup.sound_music = FALSE;
@@ -6233,7 +6233,7 @@ static void HandleGameButtons(struct GadgetInfo *gi)
        setup.sound_music = FALSE;
        FadeSound(background_loop[level_nr % num_bg_loops]);
       }
-      else if (sound_loops_allowed)
+      else if (sysinfo.audio_loops_available)
       { 
        setup.sound = setup.sound_music = TRUE;
        PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
@@ -6243,14 +6243,14 @@ static void HandleGameButtons(struct GadgetInfo *gi)
     case SOUND_CTRL_ID_LOOPS:
       if (setup.sound_loops)
        setup.sound_loops = FALSE;
-      else if (sound_loops_allowed)
+      else if (sysinfo.audio_loops_available)
        setup.sound = setup.sound_loops = TRUE;
       break;
 
     case SOUND_CTRL_ID_SIMPLE:
       if (setup.sound_simple)
        setup.sound_simple = FALSE;
-      else if (sound_status==SOUND_AVAILABLE)
+      else if (sysinfo.audio_available)
        setup.sound = setup.sound_simple = TRUE;
       break;
 
index b95b99c290fa5c81e620e2dee5e2da680b7174e6..60e0bcd3c22fd6135785dca3291bcc050e787e2f 100644 (file)
@@ -35,10 +35,6 @@ struct PictureFileInfo
   boolean picture_with_mask;
 };
 
-#ifndef TARGET_SDL
-static int sound_process_id = 0;
-#endif
-
 static void InitPlayerInfo(void);
 static void InitLevelInfo(void);
 static void InitNetworkServer(void);
@@ -146,31 +142,32 @@ void InitSound()
 {
   int i;
 
-  if (sound_status == SOUND_OFF)
+  /* REMOVE THIS! (gone to system.c:InitAudio) */
+  if (!sysinfo.audio_available)
     return;
 
 #if defined(TARGET_SDL)
   if (InitAudio())
   {
-    sound_status = SOUND_AVAILABLE;
-    sound_loops_allowed = TRUE;
+    sysinfo.audio_available = TRUE;
+    sysinfo.audio_loops_available = TRUE;
   }
   else
   {
-    sound_status = SOUND_OFF;
+    sysinfo.audio_available = FALSE;
   }
 #else /* !TARGET_SDL */
 
 #if defined(PLATFORM_UNIX)
-  if ((sound_status = CheckAudio(sound_device_name)) == SOUND_OFF)
+  if (!(sysinfo.audio_available = CheckAudio(sound_device_name)))
     return;
 
 #ifdef VOXWARE
-  sound_loops_allowed = TRUE;
+  sysinfo.audio_loops_available = TRUE;
 #endif
 
 #else /* !PLATFORM_UNIX */
-  sound_loops_allowed = TRUE;
+  sysinfo.audio_loops_available = TRUE;
 
 #endif /* !PLATFORM_UNIX */
 #endif /* !TARGET_SDL */
@@ -181,8 +178,8 @@ void InitSound()
 
     if (!LoadSound(&Sound[i]))
     {
-      sound_status = SOUND_OFF;
-      sound_loops_allowed = FALSE;
+      sysinfo.audio_available = FALSE;
+      sysinfo.audio_loops_available = FALSE;
       return;
     }
   }
@@ -190,35 +187,35 @@ void InitSound()
 
 void InitSoundServer()
 {
-  if (sound_status == SOUND_OFF)
+  if (!sysinfo.audio_available)
     return;
 
 #if !defined(TARGET_SDL)
 #if defined(PLATFORM_UNIX)
 
-  if (pipe(sound_pipe)<0)
+  if (pipe(sysinfo.audio_process_pipe) < 0)
   {
     Error(ERR_WARN, "cannot create pipe - no sounds");
-    sound_status = SOUND_OFF;
+    sysinfo.audio_available = FALSE;
     return;
   }
 
-  if ((sound_process_id = fork()) < 0)
+  if ((sysinfo.audio_process_id = fork()) < 0)
   {       
     Error(ERR_WARN, "cannot create sound server process - no sounds");
-    sound_status = SOUND_OFF;
+    sysinfo.audio_available = FALSE;
     return;
   }
 
-  if (!sound_process_id)       /* we are child */
+  if (!sysinfo.audio_process_id)       /* we are child */
   {
     SoundServer();
 
     /* never reached */
     exit(0);
   }
-  else                         /* we are parent */
-    close(sound_pipe[0]);      /* no reading from pipe needed */
+  else                                 /* we are parent */
+    close(sysinfo.audio_process_pipe[0]); /* no reading from pipe needed */
 
 #else /* !PLATFORM_UNIX */
 
@@ -1809,10 +1806,10 @@ void CloseAllAndExit(int exit_value)
   StopSounds();
   FreeSounds(NUM_SOUNDS);
 #else
-  if (sound_process_id)
+  if (sysinfo.audio_process_id)
   {
     StopSounds();
-    kill(sound_process_id, SIGTERM);
+    kill(sysinfo.audio_process_id, SIGTERM);
     FreeSounds(NUM_SOUNDS);
   }
 #endif
index b980ea24d1585761f9b73dcfb3c31dac8ca06a6a..49fde3e9941378ca31fcbe7c6535d5edf1bfb3f8 100644 (file)
@@ -35,9 +35,8 @@ Pixmap                clipmask[NUM_BITMAPS], tile_clipmask[NUM_TILES];
 DrawBuffer     drawto, drawto_field, backbuffer, fieldbuffer;
 Colormap       cmap;
 
-int            sound_pipe[2];
-int            sound_device;
 char          *sound_device_name = SOUND_DEVICE;
+
 int            joystick_device = 0;
 char          *joystick_device_name[MAX_PLAYERS] =
 {
@@ -57,8 +56,6 @@ boolean               motion_status = FALSE;
 int            key_joystick_mapping = 0;
 int            global_joystick_status = JOYSTICK_STATUS;
 int            joystick_status = JOYSTICK_STATUS;
-int            sound_status = SOUND_STATUS;
-boolean                sound_loops_allowed = FALSE;
 boolean                fullscreen_available = FULLSCREEN_STATUS;
 boolean                fullscreen_enabled = FALSE;
 
@@ -105,11 +102,12 @@ struct LevelDirInfo    *leveldir_first = NULL, *leveldir_current = NULL;
 struct LevelInfo       level;
 struct PlayerInfo      stored_player[MAX_PLAYERS], *local_player = NULL;
 struct HiScore         highscore[MAX_SCORE_ENTRIES];
-struct SoundInfo       Sound[NUM_SOUNDS];
+struct SampleInfo      Sound[NUM_SOUNDS];
 struct TapeInfo                tape;
 struct OptionInfo      options;
 struct SetupInfo       setup;
 struct GameInfo                game;
+struct SystemInfo      sysinfo;
 struct GlobalInfo      global;
 
 /* data needed for playing sounds */
index 016433e1a00dba2fea4dad86ea9537fe853943a4..705582abe1614c5ab6358c29e7f1a21148b560c7 100644 (file)
@@ -463,9 +463,8 @@ extern Pixmap               clipmask[], tile_clipmask[];
 extern DrawBuffer      drawto, drawto_field, backbuffer, fieldbuffer;
 extern Colormap                cmap;
 
-extern int             sound_pipe[2];
-extern int             sound_device;
 extern char           *sound_device_name;
+
 extern int             joystick_device;
 extern char           *joystick_device_name[];
 
@@ -478,8 +477,6 @@ extern int          button_status;
 extern boolean         motion_status;
 extern int             key_joystick_mapping;
 extern int             global_joystick_status, joystick_status;
-extern int             sound_status;
-extern boolean         sound_loops_allowed;
 extern boolean         fullscreen_available;
 extern boolean         fullscreen_enabled;
 
@@ -528,11 +525,12 @@ extern struct LevelInfo           level;
 extern struct PlayerInfo       stored_player[], *local_player;
 extern struct HiScore          highscore[];
 extern struct TapeInfo         tape;
-extern struct SoundInfo                Sound[];
+extern struct SampleInfo       Sound[];
 extern struct JoystickInfo     joystick[];
 extern struct OptionInfo       options;
 extern struct SetupInfo                setup;
 extern struct GameInfo         game;
+extern struct SystemInfo       sysinfo;
 extern struct GlobalInfo       global;
 
 extern char            *sound_name[];
index 089d1a9d1f55637e9bcafcd01ae704a05ccb7b6a..181a9f1ada1712bd03ff9bf7ab8172a55dcef1b3 100644 (file)
@@ -90,10 +90,11 @@ static void allegro_drivers()
   last_joystick_state = 0;
   joystick_event = FALSE;
 
+  sysinfo.audio_available = TRUE;
   reserve_voices(MAX_SOUNDS_PLAYING, 0);
   if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1)
     if (install_sound(DIGI_SB, MIDI_NONE, NULL) == -1)
-      sound_status = SOUND_OFF;
+      sysinfo.audio_available = FALSE;
 }
 
 static boolean hide_mouse(Display *display, int x, int y,
index 903f1165012131a01990fab5fd5eec37c19a1478..6c40c6958d3c99f9a827a27d1056ead3440b639f 100644 (file)
 #define PLATFORM_UNIX
 #endif
 
+/* define additional keywords for several Unix platforms */
+
+#if defined(__FreeBSD__)
+#define PLATFORM_FREEBSD
+#endif
+
+/* detecting HP-UX by the following compiler keyword definitions:
+   - in K&R mode (the default), the HP C compiler defines "hpux"
+   - in ANSI mode (-Aa or -Ae), the HP C compiler defines "__hpux"
+   - the gcc (Gnu) C compiler defines "__hpux__"
+   Thanks to Jarkko Hietaniemi  for this note. */
+
+#if defined(__hpux__) || defined(__hpux) || defined(hpux)
+#define PLATFORM_HPUX
+#endif
+
 #endif /* PLATFORM_H */
index 1723c6025d8c2c47fe066e0febba2980dfb698ab..b97c44a134777973bdf98284cb50733a7e7728ee 100644 (file)
@@ -1409,7 +1409,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
     {
       int yy = y-1;
 
-      if (y==3 && sound_status==SOUND_AVAILABLE)
+      if (y == 3 && sysinfo.audio_available)
       {
        if (setup.sound)
        {
@@ -1423,7 +1423,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.sound = !setup.sound;
       }
-      else if (y==4 && sound_loops_allowed)
+      else if (y == 4 && sysinfo.audio_loops_available)
       {
        if (setup.sound_loops)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1435,7 +1435,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
        }
        setup.sound_loops = !setup.sound_loops;
       }
-      else if (y==5 && sound_loops_allowed)
+      else if (y == 5 && sysinfo.audio_loops_available)
       {
        if (setup.sound_music)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1449,7 +1449,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
       }
 
 #if 0
-      else if (y==6)
+      else if (y == 6)
       {
        if (setup.toons)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1457,7 +1457,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.toons = !setup.toons;
       }
-      else if (y==7)
+      else if (y == 7)
       {
 #if 0
        if (setup.double_buffering)
@@ -1474,7 +1474,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
       }
 #endif
 
-      else if (y==6)
+      else if (y == 6)
       {
        if (setup.scroll_delay)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1482,7 +1482,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.scroll_delay = !setup.scroll_delay;
       }
-      else if (y==7)
+      else if (y == 7)
       {
        if (setup.soft_scrolling)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1491,7 +1491,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
        setup.soft_scrolling = !setup.soft_scrolling;
       }
 #if 0
-      else if (y==8)
+      else if (y == 8)
       {
        if (setup.fading)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1500,7 +1500,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
        setup.fading = !setup.fading;
       }
 #endif
-      else if (y==8 && fullscreen_available)
+      else if (y == 8 && fullscreen_available)
       {
        if (setup.fullscreen)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1508,7 +1508,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.fullscreen = !setup.fullscreen;
       }
-      else if (y==9)
+      else if (y == 9)
       {
        if (setup.quick_doors)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1516,7 +1516,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.quick_doors = !setup.quick_doors;
       }
-      else if (y==10)
+      else if (y == 10)
       {
        if (setup.autorecord)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1524,7 +1524,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.autorecord = !setup.autorecord;
       }
-      else if (y==11)
+      else if (y == 11)
       {
        if (setup.team_mode)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1532,7 +1532,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.team_mode = !setup.team_mode;
       }
-      else if (y==12)
+      else if (y == 12)
       {
        if (setup.handicap)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1540,7 +1540,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.handicap = !setup.handicap;
       }
-      else if (y==13)
+      else if (y == 13)
       {
        if (setup.time_limit)
          DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
@@ -1548,7 +1548,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
          DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
        setup.time_limit = !setup.time_limit;
       }
-      else if (y==14)
+      else if (y == 14)
       {
        game_status = SETUPINPUT;
        DrawSetupInputScreen();
index 51b0f1262053e4b18324f567892e1ba36ceae277..185b1822d9bbe3213a927ba37c803a671897107a 100644 (file)
@@ -104,7 +104,7 @@ void SoundServer()
   struct SoundControl snd_ctrl;
   fd_set sound_fdset;
 
-  close(sound_pipe[1]);                /* no writing into pipe needed */
+  close(sysinfo.audio_process_pipe[1]);        /* no writing into pipe needed */
 #endif
 
   for(i=0;i<MAX_SOUNDS_PLAYING;i++)
@@ -122,15 +122,16 @@ void SoundServer()
 #endif
 
   FD_ZERO(&sound_fdset); 
-  FD_SET(sound_pipe[0], &sound_fdset);
+  FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
 
   while(1)     /* wait for sound playing commands from client */
   {
-    FD_SET(sound_pipe[0], &sound_fdset);
-    select(sound_pipe[0]+1, &sound_fdset, NULL, NULL, NULL);
-    if (!FD_ISSET(sound_pipe[0], &sound_fdset))
+    FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
+    select(sysinfo.audio_process_pipe[0] + 1, &sound_fdset, NULL, NULL, NULL);
+    if (!FD_ISSET(sysinfo.audio_process_pipe[0], &sound_fdset))
       continue;
-    if (read(sound_pipe[0], &snd_ctrl, sizeof(snd_ctrl)) != sizeof(snd_ctrl))
+    if (read(sysinfo.audio_process_pipe[0], &snd_ctrl, sizeof(snd_ctrl))
+       != sizeof(snd_ctrl))
       Error(ERR_EXIT_SOUND_SERVER, "broken pipe - no sounds");
 
 #ifdef VOXWARE
@@ -153,7 +154,7 @@ void SoundServer()
        playlist[i]=emptySoundControl;
       playing_sounds=0;
 
-      close(sound_device);
+      close(sysinfo.audio_fd);
     }
     else if (snd_ctrl.stop_sound)
     {
@@ -168,7 +169,7 @@ void SoundServer()
        }
 
       if (!playing_sounds)
-       close(sound_device);
+       close(sysinfo.audio_fd);
     }
 
     if (playing_sounds || snd_ctrl.active)
@@ -188,7 +189,7 @@ void SoundServer()
 #endif
 
       if (playing_sounds ||
-         (sound_device = OpenAudio(sound_device_name)) >= 0)
+         (sysinfo.audio_fd = OpenAudio(sound_device_name)) >= 0)
       {
        if (!playing_sounds)    /* we just opened the audio device */
        {
@@ -196,12 +197,13 @@ void SoundServer()
          /* (with stereo the effective buffer size will shrink to 256) */
          fragment_size = 0x00020009;
 
-         if (ioctl(sound_device, SNDCTL_DSP_SETFRAGMENT, &fragment_size) < 0)
+         if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_SETFRAGMENT, &fragment_size)
+             < 0)
            Error(ERR_EXIT_SOUND_SERVER,
                  "cannot set fragment size of /dev/dsp - no sounds");
 
          /* try if we can use stereo sound */
-         if (ioctl(sound_device, SNDCTL_DSP_STEREO, &stereo) < 0)
+         if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0)
          {
 #ifdef DEBUG
            static boolean reported = FALSE;
@@ -215,12 +217,13 @@ void SoundServer()
            stereo = FALSE;
          }
 
-         if (ioctl(sound_device, SNDCTL_DSP_SPEED, &sample_rate) < 0)
+         if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_SPEED, &sample_rate) < 0)
            Error(ERR_EXIT_SOUND_SERVER,
                  "cannot set sample rate of /dev/dsp - no sounds");
 
          /* get the real fragmentation size; this should return 512 */
-         if (ioctl(sound_device, SNDCTL_DSP_GETBLKSIZE, &fragment_size) < 0)
+         if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_GETBLKSIZE, &fragment_size)
+             < 0)
            Error(ERR_EXIT_SOUND_SERVER,
                  "cannot get fragment size of /dev/dsp - no sounds");
 
@@ -231,9 +234,10 @@ void SoundServer()
          SoundServer_InsertNewSound(snd_ctrl);
 
        while(playing_sounds &&
-             select(sound_pipe[0]+1,&sound_fdset,NULL,NULL,&delay)<1)
+             select(sysinfo.audio_process_pipe[0] + 1,
+                    &sound_fdset, NULL, NULL, &delay) < 1)
        {       
-         FD_SET(sound_pipe[0], &sound_fdset);
+         FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
 
          /* first clear the last premixing buffer */
          memset(premix_last_buffer,0,fragment_size*sizeof(int));
@@ -330,12 +334,12 @@ void SoundServer()
          }
 
          /* finally play the sound fragment */
-         write(sound_device,playing_buffer,fragment_size);
+         write(sysinfo.audio_fd, playing_buffer,fragment_size);
        }
 
        /* if no sounds playing, free device for other sound programs */
        if (!playing_sounds)
-         close(sound_device);
+         close(sysinfo.audio_fd);
       }
     }
 
@@ -350,14 +354,15 @@ void SoundServer()
       int wait_percent = 90;   /* wait 90% of the real playing time */
       int i;
 
-      if ((sound_device = OpenAudio(sound_device_name)) >= 0)
+      if ((sysinfo.audio_fd = OpenAudio(sound_device_name)) >= 0)
       {
        playing_sounds = 1;
 
        while(playing_sounds &&
-             select(sound_pipe[0]+1,&sound_fdset,NULL,NULL,&delay)<1)
+             select(sysinfo.audio_process_pipe[0] + 1,
+                    &sound_fdset, NULL, NULL, &delay) < 1)
        {       
-         FD_SET(sound_pipe[0], &sound_fdset);
+         FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset);
 
          /* get pointer and size of the actual sound sample */
          sample_ptr = snd_ctrl.data_ptr + snd_ctrl.playingpos;
@@ -384,12 +389,12 @@ void SoundServer()
            playing_sounds = 0;
 
          /* finally play the sound fragment */
-         write(sound_device,playing_buffer,sample_size);
+         write(sysinfo.audio_fd,playing_buffer,sample_size);
 
          delay.tv_sec = 0;
          delay.tv_usec = ((sample_size*10*wait_percent)/(sample_rate))*1000;
        }
-       close(sound_device);
+       close(sysinfo.audio_fd);
       }
     }
 
@@ -603,7 +608,7 @@ static void SoundServer_StopSound(int nr)
 
 #if !defined(PLATFORM_MSDOS)
   if (!playing_sounds)
-    close(sound_device);
+    close(sysinfo.audio_fd);
 #endif
 }
 
@@ -622,7 +627,7 @@ static void SoundServer_StopAllSounds()
   playing_sounds = 0;
 
 #if !defined(PLATFORM_MSDOS)
-  close(sound_device);
+  close(sysinfo.audio_fd);
 #endif
 }
 #endif /* PLATFORM_MSDOS */
@@ -767,7 +772,7 @@ static int ulaw_to_linear(unsigned char ulawbyte)
 #define CHUNK_ID_LEN            4       /* IFF style chunk id length */
 #define WAV_HEADER_SIZE                20      /* size of WAV file header */
 
-boolean LoadSound(struct SoundInfo *snd_info)
+boolean LoadSound(struct SampleInfo *snd_info)
 {
   char filename[256];
   char *sound_ext = "wav";
@@ -886,7 +891,7 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop)
 {
   struct SoundControl snd_ctrl = emptySoundControl;
 
-  if (sound_status==SOUND_OFF || !setup.sound)
+  if (!sysinfo.audio_available || !setup.sound)
     return;
 
   if (volume<PSND_MIN_VOLUME)
@@ -916,10 +921,10 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop)
 
 #else
 #if !defined(PLATFORM_MSDOS)
-  if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
+  if (write(sysinfo.audio_process_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
   {
     Error(ERR_WARN, "cannot pipe to child process - no sounds");
-    sound_status = SOUND_OFF;
+    sysinfo.audio_available = FALSE;
     return;
   }
 #else
@@ -952,7 +957,7 @@ void StopSoundExt(int nr, int method)
 {
   struct SoundControl snd_ctrl = emptySoundControl;
 
-  if (sound_status==SOUND_OFF)
+  if (!sysinfo.audio_available)
     return;
 
   if (SSND_FADING(method))
@@ -981,10 +986,10 @@ void StopSoundExt(int nr, int method)
 
 #else
 #if !defined(PLATFORM_MSDOS)
-  if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
+  if (write(sysinfo.audio_process_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
   {
     Error(ERR_WARN, "cannot pipe to child process - no sounds");
-    sound_status = SOUND_OFF;
+    sysinfo.audio_available = FALSE;
     return;
   }
 #else
@@ -997,7 +1002,7 @@ void FreeSounds(int num_sounds)
 {
   int i;
 
-  if (sound_status == SOUND_OFF)
+  if (!sysinfo.audio_available)
     return;
 
   for(i=0; i<num_sounds; i++)
index 28d7ba21ef2d8c89099d165c9138e07655cf3fb4..811a7bb9c9ee620c99786eb56dbd8c0990de3b8e 100644 (file)
@@ -125,7 +125,7 @@ struct SoundHeader_8SVX
   char magic_8SVX[4];
 };
 
-struct SoundInfo
+struct SampleInfo
 { 
   char *name;
   byte *data_ptr;
@@ -169,7 +169,7 @@ boolean UnixInitAudio(void);
 void SoundServer(void);
 
 /* sound client functions */
-boolean LoadSound(struct SoundInfo *);
+boolean LoadSound(struct SampleInfo *);
 void PlaySound(int);
 void PlaySoundStereo(int, int);
 void PlaySoundLoop(int);
index 54870c81a92398147445837564f9620b73482f89..bfc0c0e8c97c3d10290637590c8263bb90f0d289 100644 (file)
@@ -235,6 +235,12 @@ inline void ChangeVideoModeIfNeeded(void)
 
 inline boolean InitAudio(void)
 {
+  sysinfo.audio_available = TRUE;
+  sysinfo.audio_loops_available = FALSE;
+
+  if (!sysinfo.audio_available)
+    return FALSE;
+
 #ifdef TARGET_SDL
   return SDLInitAudio();
 #else
index 77befc6592b32b85c86f1c11ca0c0634d9707164..0e84953a407dad736dc1d4f5885a9a164bb82619 100644 (file)
@@ -28,7 +28,7 @@
 #endif
 
 
-/* system-wide contant definitions */
+/* contant definitions */
 
 #define DEFAULT_DEPTH                  0
 
 #define FULLSCREEN_AVAILABLE           TRUE
 
 
-/* system-wide type definitions */
+/* type definitions */
 
 typedef int (*EventFilter)(const Event *);
 
 
-/* system-wide function definitions */
+/* structure definitions */
+
+struct SystemInfo
+{
+  boolean audio_available;
+  boolean audio_loops_available;
+  int audio_process_id;
+  int audio_process_pipe[2];
+  int audio_fd;
+};
+
+
+/* function definitions */
 
 inline void InitBufferedDisplay(DrawBuffer *, DrawWindow *);
 inline int GetDisplayDepth(void);